|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Adding elements to unknown tree structure
Hi,
Tempore 17:41:53, die 09/21/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Gustave Stresen-Reuter <tedmasterweb@xxxxxxx>: Given:
<xsl:template match="node()"> <xsl:param name="path2folder"/> <xsl:param name="good" select="true()"/> <xsl:variable name="path" select="substring-before($path2folder,'/')"/> <xsl:variable name="verygood" select="($good and @name=$path) or self::myxmlfile"/> <xsl:variable name="pathafter" select="substring-after($path2folder,'/')"/> <xsl:variable name="nextpath" select="substring-before($pathafter,'/')"/> <xsl:variable name="folder" select="folder[@name=$nextpath][$good]"/> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates select="node()"> <xsl:with-param name="path2folder" select="$pathafter"/> <xsl:with-param name="good" select="$verygood"/> </xsl:apply-templates> <xsl:if test="$verygood and not($folder) and not($path2folder='')"> <xsl:call-template name="createFolder"> <xsl:with-param name="path2folder" select="$pathafter"/> </xsl:call-template> </xsl:if> </xsl:copy> </xsl:template> <xsl:template name="createFolder">
<xsl:param name="path2folder"/>
<folder name="{substring-before(concat($path2folder,'/'),'/')}">
<xsl:if test="contains($path2folder,'/')">
<xsl:call-template name="createFolder">
<xsl:with-param name="path2folder"
select="substring-after($path2folder,'/')"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="not(contains($path2folder,'/'))">
<xsl:comment>folder inserted</xsl:comment>
</xsl:if>
</folder>
</xsl:template></xsl:stylesheet> regards, -- Joris Gillis (http://users.telenet.be/root-jg/me.html) Don't send spam. I don't like it and it is illegal.
|
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
|

Cart








