[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Recursively link XML blocks

Subject: Re: Recursively link XML blocks
From: philippe drix <phdrix@xxxxxxx>
Date: Mon, 26 Nov 2001 21:18:05 +0100
xsl link xml

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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.