Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 19th, 2006, 05:42 AM
Registered User
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default help needed regarding xslt

 Hi..:)
I have a problem in extracting data from a file using xslt.
the problem is that i have to extract the coordinates and place them three in a row which represents a coordinate of a point in the three axes i.e X,Y,Z.
can you help me to design an xslt to do this.
i'm sending the file. i need to extract the points ((i want only Coordinate point )) not the DEF) from the tag --> <Coordinate DEF="_coord0BFD4110" point=" <---

**************************************************
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile="Full">
  <head>
    <meta name="filename" content="F:/ejector plate1.x3d"/>
    <meta name="description" content="*enter description here, short-sentence summaries preferred*"/>
    <meta name="author" content="*enter name of original author here*"/>
    <meta name="translator" content="*if manually translating VRML-to-X3D, enter name of person translating here*"/>
    <meta name="created" content="*enter date of initial version here*"/>
    <meta name="translated" content="13 April 2006"/>
    <meta name="revised" content="13 April 2006"/>
    <meta name="version" content="*enter version here*"/>
    <meta name="reference" content="*enter reference citation or relative/online url here*"/>
    <meta name="reference" content="*enter additional url/bibliographic reference information here*"/>
    <meta name="copyright" content="*enter copyright information here* Example: Copyright (c) Web3D Consortium Inc. 2002"/>
    <meta name="drawing" content="*enter drawing filename/url here*"/>
    <meta name="image" content="*enter image filename/url here*"/>
    <meta name="movie" content="*enter movie filename/url here*"/>
    <meta name="photo" content="*enter photo filename/url here*"/>
    <meta name="keywords" content="*enter keywords here*"/>
    <meta name="url" content="*enter online url address for this file here*"/>
    <meta name="generator" content="Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html"/>
  </head>
  <Scene>
  <WorldInfo info='"File created using CATIA"'/>
  <NavigationInfo type='"EXAMINE" "WALK" "FLY"'/>
  <Viewpoint position="-0.939701 -0.648956 -1.766084" orientation="0.552491 -0.833486 0.007426 2.567441" description="Main Viewpoint" fieldOfView="0.471225"/>
  <Transform scale="0.0010 0.0010 0.0010">
      <Group >
          <Group >
              <Group DEF="_0DE27DB8" >
              </Group>
          </Group>
          <Group >
              <Group DEF="_0DE262B8" >
              </Group>
          </Group>
          <Group >
              <Group DEF="_0DE24868" >
              </Group>
          </Group>
          <Group >
              <Group DEF="_0DE18288" >
                  <Shape >
                      <Appearance >
                          <Material DEF="_material0" diffuseColor="0.823529 0.823529 1.0"/>
                      </Appearance>
                      <IndexedFaceSet coordIndex=" 1514 1515 1532 -1 1515 1533 1532 -1 1532 1533 1544 -1 1533 1545 1544 -1 1544 1545 1540 -1 1545 1541 1540 -1 1540 1541 1520 -1 1541 1521 1520 -1 1520 1521 1496 -1 1521 1497 1496 -1 1496 1497 1474 -1 1497 1475 1474 -1 1474 1475 1446 -1 1475 1447 1446 -1 1446 1447 1408 -1 1447 1409 1408 -1 1408 1409 1380 -1 1409 1381 1380 -1 1380 1381 1336 -1 1381 1337 1336 -1 1336 1337 1314 -1 1337 1315 1314 -1 1314 1315 1278 -1 1315 1279 1278 -1 1278 1279 1250 -1 1279 1251 1250 -1 1250 1251 1226 -1 1251 1227 1226 -1" solid="false">
                          <Coordinate DEF="_coord0BFD4110" point="-240.0 -148.0 2.0, -240.0 -148.0 2.0, -240.0 -148.0 28.0, -240.0 -148.0 28.0, -240.0 148.0 2.0, -240.0 148.0 2.0, -240.0 148.0 28.0, -240.0 148.0 28.0, -239.0 -149.0 1.0, -239.0 -149.0 1.0, -239.0 -149.0 1.0, -239.0 -149.0 29.0, -239.0 -149.0 29.0, -239.0 -149.0 29.0, -239.0 149.0 1.0, -239.0 149.0 1.0, -239.0 149.0 1.0, -239.0 149.0 29.0, -239.0 149.0 29.0, -239.0 149.0 29.0, -238.0 -150.0 2.0, -238.0 -150.0 2.0, -238.0 -150.0 28.0, -238.0 -150.0 28.0, -238.0 -148.0 0.0, -238.0 -148.0 0.0, -238.0 -148.0 30.0, -238.0 -148.0 30.0, -238.0 148.0 0.0, -238.0 148.0 0.0, -238.0 148.0 30.0, -238.0 148.0 30.0, -238.0 150.0 2.0, -238.0 150.0 2.0, -238.0 150.0 28.0, -238.0 150.0 28.0, -227.954 -93.7195 0.0, -227.954 -93.7195 8.0, -227.954 96.2805 0.0, -227.954 96.2805 8.0, -227.588 -98.8297 0.0, -227.588 -98.8297 8.0, -227.588 91.1703 0.0, -227.588 91.1703 8.0, -226.866 -88.713 0.0, -226.866 -88.713 8.0, -226.866 101.287 0.0, -226.866 101.287 8.0, -225.992 -129.693 0.0, -225.992 -129.693 30.0, -225.992 0.307072 0.0, -225.992 0.307072 30.0, -225.992 130.307 0.0, -225.992 130.307 30.0, -225.796 -103.63 -8.32667E-17, -225.796 -103.63 8.0, -225.796 86.3703 -8.32667E-17, -225.796 86.3703 8.0, -225.532 -132.323 0.0, -225.532 -132.323 30.0, -225.532 -2.32323 0.0, -225.532 -2.32323 30.0, -225.532 127.677 0.0, -225.532 127.677 30.0, -225.266 -127.123 0.0, -225.266 -127.123 30.0, -225.266 2.87655 0.0, -225.266 2.87655 30.0, -225.266 132.877 0.0, -225.266 132.877 30.0, -224.412 -84.2159 0.0, -224.412 -84.2159 8.0, -224.412 105.784 0.0, -224.412 105.784 8.0, -223.976 -134.493 0.0, -223.976 -134.493 30.0, -223.976 -4.49339 0.0, -223.976 -4.49339 30.0, -223.976 125.507 0.0, -223.976 125.507 30.0, -223.496 -125.124 0.0, -223.496 -125.124 30.0, -223.496 4.8763 0.0, -223.496 4.8763 30.0, -223.496 134.876 0.0, -223.496 134.876 30.0, -222.852 -96.9547 8.0, -222.852 -96.9547 30.0, -222.852 93.0453 8.0, -222.852 93.0453 30.0, -222.746 -92.4411 8.0, -222.746 -92.4411 30.0, -222.746 97.5589 8.0, -222.746 97.5589 30.0, -222.725 -107.73 0.0, -222.725 -107.73 8.0, -222.725 82.2695 0.0, -222.725 82.2695 8.0, -221.633 -135.774 0.0, -221.633 -135.774 30.0, -221.633 -5.77357 0.0, -221.633 -5.77357 30.0, -221.633 124.226 0.0, -221.633 124.226 30.0, -221.409 -101.233 8.0, -221.409 -101.233 30.0, -221.409 88.7675 8.0, -221.409 88.7675 30.0, -221.102 -88.2362 8.0, -221.102 -88.2362 30.0, -221.102 101.764 8.0, -221.102 101.764 30.0, -221.034 -124.09 0.0, -221.034 -124.09 30.0, -221.034 5.91023 0.0, -221.034 5.91023 30.0, -221.034 135.91 0.0, -221.034 135.91 30.0, -220.79 -80.5924 0.0, -220.79 -80.5924 8.0, -220.79 109.408 0.0, -220.79 109.408 8.0, -218.966 -135.91 0.0, -218.966 -135.91 30.0, -218.966 -5.91023 0.0, -218.966 -5.91023 30.0, -218.966 124.09 0.0, -218.966 124.09 30.0, -218.623 -110.8 0.0, -218.623 -110.8 8.0, -218.623 79.2 0.0, -218.623 79.2 8.0, -218.589 -104.759 8.0, -218.589 -104.759 30.0, -218.589 85.2414 8.0, -218.589 85.2414 30.0, -218.367 -124.226 0.0, -218.367 -124.226 30.0, -218.367 5.77357 0.0, -218.367 5.77357 30.0, -218.367 135.774 0.0, -218.367 135.774 30.0, -218.119 -84.847 8.0, -218.119 -84.847 30.0, -218.119 105.153 8.0, -218.119 105.153 30.0, -216.504 -134.876 0.0, -216.504 -134.876 30.0, -216.504 -4.8763 0.0, -216.504 -4.8763 30.0, -216.504 125.124 0.0, -216.504 125.124 30.0, -216.294 -78.1362 0.0, -216.294 -78.1362 8.0, -216.294 111.864 0.0, -216.294 111.864 8.0, -216.024 -125.507 0.0, -216.024 -125.507 30.0, -216.024 4.49339 0.0, -216.024 4.49339 30.0, -216.024 134.493 0.0, -216.024 134.493 30.0, -214.734 -132.877 0.0, -214.734 -132.877 30.0, -214.734 -2.87655 0.0, -214.734 -2.87655 30.0, -214.734 127.123 0.0, -214.734 127.123 30.0, -214.733 -107.108 8.0, -214.733 -107.108 30.0, -214.733 82.8923 8.0, -214.733 82.8923 30.0, -214.468 -127.677 0.0, -214.468 -127.677 30.0, -214.468 2.32323 0.0, -214.468 2.32323 30.0, -214.468 132.323 0.0, -214.468 132.323 30.0, -214.157 -82.6825 8.0, -214.157 -82.6825 30.0, -214.157 107.318 8.0, -214.157 107.318 30.0, -214.008 -130.307 0.0, -214.008 -130.307 30.0, -214.008 -0.307072 0.0, -214.008 -0.307072 30.0, -214.008 129.693 0.0, -214.008 129.693 30.0, -213.823 -112.589 0.0, -213.823 -112.589 8.0, -213.823 77.4106 0.0, -213.823 77.4106 8.0, -211.288 -77.0461 0.0, -211.288 -77.0461 8.0, -211.288 112.954 0.0, -211.288 112.954 8.0, -210.307 -107.996 8.0, -210.307 -107.996 30.0, -210.307 82.0036 8.0, -210.307 82.0036 30.0, -209.693 -82.0036 8.0, -209.693 -82.0036 30.0, -209.693 107.996 8.0, -209.693 107.996 30.0, -208.712 -112.954 0.0, -208.712 -112.954 8.0, -208.712 77.0461 0.0, -208.712 77.0461 8.0, -206.177 -77.4106 0.0, -206.177 -77.4106 8.0, -206.177 112.589 0.0, -206.177 112.589 8.0, -205.843 -107.318 8.0, -205.843 -107.318 30.0, -205.843 82.6825 8.0, -205.843 82.6825 30.0, -205.267 -82.8923 8.0, -205.267 -82.8923 30.0, -205.267 107.108 8.0, -205.267 107.108 30.0, -205.0 -150.0 2.0, -205.0 -150.0 2.0, -205.0 -150.0 3.0, -205.0 150.0 2.0, -205.0 150.0 2.0, -205.0 150.0 3.0, -204.866 -148.0 0.0, -204.866 -148.0 0.0, -204.866 148.0 0.0, -204.866 148.0 0.0, -204.534 146.289 3.0, -204.359 -145.66 3.0, -204.253 145.326 0.0, -203.706 -111.864 0.0, -203.706 -111.864 8.0, -203.706 78.1362 0.0, -203.706 78.1362 8.0, -203.525 -143.513 0.0, -203.164 142.809 -8.32667E-17, -203.164 142.809 3.0, -202.489 -141.692 3.0, -201.881 -105.153 8.0, -201.881 -105.153 30.0, -201.881 84.847 8.0, -201.881 84.847 30.0, -201.411 -85.2414 8.0, -201.411 -85.2414 30.0, -201.411 104.759 8.0, -201.411 104.759 30.0, -201.377 -79.2 0.0, -201.377 -79.2 8.0, -201.377 110.8 0.0, -201.377 110.8 8.0, -200.865 -139.659 0.0, -200.52 139.308 3.0, -200.305 139.1 0.0, -199.551 -138.434 3.0, -199.21 -109.408 0.0, -199.21 -109.408 8.0, -199.21 80.5924 0.0, -199.21 80.5924 8.0, -198.898 -101.764 8.0, -198.898 -101.764 30.0, -198.898 88.2362 8.0, -198.898 88.2362 30.0, -198.591 -88.7675 8.0, -198.591 -88.7675 30.0, -198.591 101.233 8.0, -198.591 101.233 30.0, -197.275 -82.2695 0.0, -197.275 -82.2695 8.0, -197.275 107.73 0.0, -197.275 107.73 8.0, -197.254 -97.5589 8.0, -197.254 -97.5589 30.0, -197.254 92.4411 8.0, -197.254 92.4411 30.0, -197.148 -93.0453 8.0, -197.148 -93.0453 30.0, -197.148 96.9547 8.0, -197.148 96.9547 30.0, -197.147 -136.812 0.0, -196.977 136.721 3.0, -196.441 136.453 0.0, -195.796 -136.165 3.0, -195.588 -105.784 0.0, -195.588 -105.784 8.0, -195.588 84.2159 0.0, -195.588 84.2159 8.0, -194.204 -86.3703 -8.32667E-17, -194.204 -86.3703 8.0, -194.204 103.63 -8.32667E-17, -194.204 103.63 8.0, -193.134 -101.287 0.0, -193.134 -101.287 8.0, -193.134 88.713 0.0, -193.134 88.713 8.0, -192.837 135.271 3.0, -192.732 -135.251 0.0, -192.412 -91.1703 0.0, -192.412 -91.1703 8.0, -192.412 98.8297 0.0, -192.412 98.8297 8.0, -192.046 -96.2805 0.0, -192.046 -96.2805 8.0, -192.046 93.7195 0.0, -192.046 93.7195 8.0, -191.95 135.127 0.0, -191.546 -135.08 3.0, -188.463 -111.459 0.0, -188.463 -111.459 3.0, -188.463 108.541 0.0, -188.463 108.541 3.0, -188.454 135.08 3.0, -188.074 -105.088 0.0, -188.074 -105.088 3.0, -188.074 114.912 0.0, -188.074 114.912 3.0, -188.05 -135.127 0.0, -187.424 -117.756 0.0, -187.424 -117.756 3.0, -187.424 102.244 0.0, -187.424 102.244 3.0, -187.268 135.251 0.0, -187.163 -135.271 3.0, -186.277 -98.9647 0.0, -186.277 -98.9647 3.0, -186.277 121.035 0.0, -186.277 121.035 3.0, -185.011 -123.664 -8.32667E-17, -185.011 -123.664 3.0, -185.011 96.3364 -8.32667E-17, -185.011 96.3364 3.0, -184.204 136.165 3.0, -183.559 -136.453 0.0, -183.162 -93.3942 0.0, -183.162 -93.3942 3.0, -183.162 126.606 0.0, -183.162 126.606 3.0, -183.023 -136.721 3.0, -182.853 136.812 0.0, -182.494 -109.469 3.0, -182.494 -109.469 30.0, -182.494 110.531 3.0, -182.494 110.531 30.0, -181.865 -115.309 3.0, -181.865 -115.309 30.0, -181.865 104.691 3.0, -181.865 104.691 30.0, -181.59 -103.665 3.0, -181.59 -103.665 30.0, -181.59 116.335 3.0, -181.59 116.335 30.0, -181.344 -128.887 0.0, -181.344 -128.887 3.0, -181.344 91.1135 0.0, -181.344 91.1135 3.0, -180.449 138.434 3.0, -179.746 -120.787 3.0, -179.746 -120.787 30.0, -179.746 99.2129 3.0, -179.746 99.2129 30.0, -179.695 -139.1 0.0, -179.48 -139.308 3.0, -179.215 -98.2933 3.0, -179.215 -98.2933 30.0, -179.215 121.707 3.0, -179.215 121.707 30.0, -179.135 139.659 0.0, -178.887 -88.6564 0.0, -178.887 -88.6564 3.0, -178.887 131.344 0.0, -178.887 131.344 3.0, -177.511 141.692 3.0, -176.836 -142.809 -8.32667E-17, -176.836 -142.809 3.0, -176.606 -133.162 0.0, -176.606 -133.162 3.0, -176.606 86.8376 0.0, -176.606 86.8376 3.0, -176.475 143.513 0.0, -176.281 -125.53 3.0, -176.281 -125.53 30.0, -176.281 94.4699 3.0, -176.281 94.4699 30.0, -175.747 -145.326 0.0, -175.641 145.66 3.0, -175.53 -93.7191 3.0, -175.53 -93.7191 30.0, -175.53 126.281 3.0, -175.53 126.281 30.0, -175.466 -146.289 3.0, -175.134 -148.0 0.0, -175.134 -148.0 0.0, -175.134 148.0 0.0, -175.134 148.0 0.0, -175.0 -150.0 2.0, -175.0 -150.0 2.0, -175.0 -150.0 3.0, -175.0 150.0 2.0, -175.0 150.0 2.0, -175.0 150.0 3.0, -173.664 -84.9889 0.0, -173.664 -84.9889 3.0, -173.664 135.011 0.0, -173.664 135.011 3.0, -171.707 -129.215 3.0, -171.707 -129.215 30.0, -171.707 90.7853 3.0, -171.707 90.7853 30.0, -171.035 -136.277 0.0, -171.035 -136.277 3.0, -171.035 83.7232 0.0, -171.035 83.7232 3.0, -170.787 -90.2544 3.0, -170.787 -90.2544 30.0,

(this is just a part of file... it's not closed correctly)



 
Old April 19th, 2006, 05:58 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You haven't said what output you want but I guess it's something like

<coordinate>
  <point X="-240.0" Y="-148.0" Z="2.0"/>
  <point X="-240.0" Y="-148.0" Z="28.0"/>
  etc...

This is easiest to achieve with XSLT 2.0, where you can call tokenize() to split the string using "," as a delimiter, then split each substring again using tokenize() but using space as a delimiter.

In XSLT 1.0 you'll need to write a recursive template that uses substring-before() and substring-after(). To split a string at commas, use substring-before() to get what comes before the first comma, then make a recursive call to process the rest of the string after the first comma. You'll find an example of this in the str:tokenize template which you can download from www.exslt.org - you may be able to use this code directly in your stylesheet, or you may prefer to adapt it to your specific requirements.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed on XSLT baruprasad XSLT 8 October 21st, 2008 09:03 AM
help needed in XSLT ddeokarb XSLT 1 November 22nd, 2007 10:41 AM
XSLT Help Needed JZen XSLT 9 February 22nd, 2007 04:27 AM
xslt help desperately needed daula7 XSLT 2 May 10th, 2006 12:09 PM
help needed for xslt rameshnarayan XSLT 2 September 19th, 2005 03:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.