xsl-list
[Top] [All Lists]

Re: urgent..creating loops in output xml based on input xml values..

2005-09-12 02:48:14
Tempore 11:14:52, die 09/12/2005 AD, hinc in 
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit ma he 
<mahendranvm(_at_)yahoo(_dot_)co(_dot_)in>:

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=". &gt;= $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>


regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Laudeo W3C et dona ferens

--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>