[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Axis-Name help


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

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