Subject: Re: [xsl] Recursively link XML blocks From: philippe drix <phdrix@xxxxxxx> Date: Mon, 26 Nov 2001 21:18:05 +0100 |
Costantino_Sertorio@xxxxxxxxxx wrote: > > Hello everybody, > I am trying (without success, at the moment...) to do the following: > > XML document: > ... > <element_A> > textA textA textA > <insert>element_B</insert> > textA textA textA > </element_A> > > <element_B> > textB textB textB > <insert>element_C</insert> > textB textB textB > </element_B> > > <element_C> > textC textC textC > textC textC textC > </element_C> > ....etc. > > Desired output: > textA textA textA > textB textB textB > textC textC textC > textC textC textC > textB textB textB > textA textA textA > Hello, try this : <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method='text' encoding='ISO-8859-1' /> <xsl:template match="/"> <xsl:call-template name="make_insert"> <xsl:with-param name="elem" select="'element_A'" /> </xsl:call-template> </xsl:template> <xsl:template match="insert"> <xsl:call-template name="make_insert"> <xsl:with-param name="elem" select="." /> </xsl:call-template> </xsl:template> <xsl:template name="make_insert"> <xsl:param name="elem"/> <xsl:for-each select="//*[name() = $elem ]" > <xsl:value-of select="./child::text()[1]"/> <xsl:apply-templates/> <xsl:value-of select="./child::text()[2]"/> </xsl:for-each> </xsl:template> <xsl:template match="text()"/> </xsl:stylesheet> Philippe Drix www.objectiva.fr XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Recursively link XML bloc, Mitch C. Amiano | Thread | |
Re: [xsl] Diff table for spotted no, Jörg Heinicke | Date | [xsl] Creating a container?, Michael Müller-Hille |
Month |