[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: urgent..creating loops in output xml based on inpu
Tempore 11:14:52, die 09/12/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit ma he <mahendranvm@xxxxxxxxxxx>:
Here's a working XSLT 1.0 solution. Please take the time understand it when you're not in a hurry anymore. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="root"> <xsl:copy> <xsl:apply-templates select="name[.='1']"/> </xsl:copy> </xsl:template> <xsl:template match="name"> <Loop> <xsl:copy-of select="."/> <xsl:apply-templates select="following::name[1]" mode="recursive"> <xsl:with-param name="level" select="number(.)+1"/> </xsl:apply-templates> </Loop> </xsl:template> <xsl:template match="name" mode="recursive"> <xsl:param name="level"/> <xsl:if test="number(.)=$level"> <xsl:apply-templates select="."/> </xsl:if> <xsl:if test=". >= $level"> <xsl:apply-templates select="following::name[1]" mode="recursive"> <xsl:with-param name="level" select="$level"/> </xsl:apply-templates> </xsl:if> </xsl:template> </xsl:s tylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|