Hello,
I'm trying to figure out the best way to transform a node-set only if it
includes certain nodes, Lets assume I have the following xml structure:
<tree>
<controls>
<control>
<dummy><data>some data</data></dummy>
<item1><data>some data</data></item1>
<item2><data>some data</data></item2>
</control>
<control>
<dummy><data>some data</data></dummy>
<item1><data>some data</data></item1>
<item2><data>some data</data></item2>
</control>
</controls>
</tree>
I want to select the values of item1's data and item2's data so I'm doing
this:
<xsl:for-each select="/tree/controls/control">
<xsl:value-of select="item1/data"/>
<xsl:value-of select="item2/data"/>
</xsl:for-each>
This is all fine but my problem begins when there're more "control" nodes
with no item1 or item2 children. So if there's one more "control" child (for
the example above) which is empty then the for loop will itterate 3 times
while I need it to itterate only 2 times for real values. I thought about
doing something like:
<xsl:for-each select="/tree/controls/control/item1">
<xsl:value-of select="data"/>
<xsl:value-of select="../item2/data"/>
</xsl:for-each>
But I'm hoping that there's a more celver way to do what I want.
Thank you very much
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--