[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Axis-Name help

Subject: Axis-Name help
From: "bix xslt" <bix_xslt@xxxxxxxxxxx>
Date: Wed, 22 Jan 2003 22:38:50 +0000
xslt axis names
All,

Given this type of tree structure:

<!ELEMENT grandp (parent)*>
<!ELEMENT parent (child)*>
<!ELEMENT child EMPTY>

I am trying to reference each child by a specific position. I have included a 'pos' attribute just for clarity. It is not part of my dataset. In other words, suppose I have the following:

<grandp pos='na'>
 <parent pos='1'>
   <child pos='1'>
   <child pos='2'>
   <child pos='3'>
   <child pos='4'>
 </parent>
 <parent pos='2'>
   <child pos='1'>
   <child pos='2'>
   <child pos='3'>
   <child pos='4'>
 </parent>
 <parent pos='3'>
   <child pos='1'>
   <child pos='2'>
   <child pos='3'>
   <child pos='4'>
 </parent>
 <parent pos='4'>
   <child pos='1'>
   <child pos='2'>
   <child pos='3'>
   <child pos='4'>
 </parent>
</grandp>

I create a nodeset that only contains the 'child' nodes which have a position 1 (ie. pos='1'). Another way to describe this visually would be to create a tabular format:

parent(1)  child(1) child(2) child(3) child(4)
parent(2)  child(1) child(2) child(3) child(4)
parent(3)  child(1) child(2) child(3) child(4)
parent(4)  child(1) child(2) child(3) child(4)

I want to create a nodeset for a variable which contains each column of data.

My limited knowledge made me think this might work...but as testing will show, it does not:
<x:template match="/">
<x:for-each select="grandp/parent">
....code....
<x:variable name="pos" select="$someCorrectPosition" />
....code....
<x:variable name="nodeSet">
<x:value-of select="parent::*/child::*/child::*[position()=$pos" />
</x:variable>
...operate on the nodeSet variable...
</x:for-each>
</x:template>


Thanks in advance!
Bix

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.