This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Recursively link XML blocks
- From: philippe drix <phdrix at free dot fr>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Mon, 26 Nov 2001 21:18:05 +0100
- Subject: Re: [xsl] Recursively link XML blocks
- References: <85256B0A.003588C9.00@ams-central-gate-5a.amsinc.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Costantino_Sertorio@amsinc.com 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