hi,
try the following. I'm inserting an end tag for "item" when I see the first
"option" node and then processing the following "option" nodes.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- for every item node in document-->
<xsl:template match="//item">
<!--for the first stuff node under item-->
<xsl:if test="name((./*)[1])='stuff'">
<xsl:value-of select="'<item>'" disable-output-escaping="yes"/>
<xsl:copy-of select="stuff"/>
<xsl:value-of select="'</item>'" disable-output-escaping="yes"/>
</xsl:if>
<!--for all the option nodes under item -->
<xsl:for-each select="option">
<xsl:element name="item">
<xsl:element name="stuff">
<xsl:value-of select="option_stuff"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
hope that helps,
swapna
"Gabe Moothart" <ga**@imaginesystems.net> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi,
I need some help figuring out how to do something in xslt. I have an xml
document with a list of items. Each item in turn can have a list of
options, like so:
<item>
<stuff>Item 1 Stuff</stuff>
<option>
<option_stuff>Option 1 Stuff</option_stuff>
</option>
<option>
<option_stuff>Option 2 Stuff</option_stuff>
</option>
...
</item>
...
I need to transform that by turning the option tags into item tags, and
making them siblings of their parent item, like so:
<item>
<stuff>Item 1 Stuff</stuff>
</item>
<item>
<stuff>Option 1 Stuff</stuff>
</item>
<item>
<stuff>Option 2 Stuff</stuff>
</item>
...
The ordering needs to be preserved, so that the item1 node comes before
the options, and the item1 options come before the item2 node, etc. How
can I accomplish this with xslt?
thanks,
Gabe