It would be helpful if you shared your input XML, along with the
stylesheet and the output example, but I think I see what you are
going for.. Here is a fragment demonstrating the pattern I think you
need.
<xsl:template match="list1">
<list1>
<text>
<xsl:value-of select="text"/>
</text>
<xsl:apply-templates select="list2/text"/>
</list1>
</xsl:template>
- michael dykman
On Thu, Jul 23, 2009 at 6:38 PM, kurps s<kurpss(_at_)gmail(_dot_)com> wrote:
Hi
I am trying to create a nested XML list using xslt.The XL should have 4
levels.
<list1>
<text></text>
<list2>
<text></text>
<list3>
<text></text>
<list4>
<text></text>
</list4>
</list3>
<list3>
<text></text>
</list3>
<list3>
<text></text>
</list3>
</list2>
<list2>
<text></text>
</list2>
</list1>
Now there can be any number of list elements within each other. Like
in the example abbove, there can be multiple <list3> within <list2>.
The trick is to make sure that the first list3 gets closed after
<list4> , and a new <list3> opens after the first closes.
My XSLT program is just creating a continuous list instead of counting
the levels.
<xsl:template match="list1/text">
<list1>
<text>
<xsl:value-of select="."/>
</text>
<xsl:choose>
<xsl:apply-templates select="list2/text"/>
</list1>
</xsl:template>
<xsl:template match="list2/text">
<list2>
<text>
<xsl:value-of select="."/>
</text>
<xsl:apply-templates select=”list3/text”/>
</list2>
</xsl:template>
<xsl:template match="list3/text">
<list3>
<text>
<xsl:value-of select="."/>
</text>
<xsl:apply-templates select=”list4/text”/>
</list3>
</xsl:template>
<xsl:template match="list4/text">
<list4>
<text>
<xsl:value-of select="."/>
</text>
</list4>
</xsl:template>
Can anyone help me here?
Thanks in advance for your help.
--~------------------------------------------------------------------
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>
--~--
--
- michael dykman
- mdykman(_at_)gmail(_dot_)com
- All models are wrong. Some models are useful.
--~------------------------------------------------------------------
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>
--~--