|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Recursively link XML blocks
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
|
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








