RE: select nodes only one level with same name

Subject: RE: select nodes only one level with same name
From: Mark Birbeck <Mark.Birbeck@xxxxxxxxxxxxx>
Date: Mon, 24 May 1999 17:17:28 +0100
There are a number of ways. One is to nest your template tags:

<xsl:template match="/">
    <xsl:apply-templates>
        <xsl:template match="operation">
            do something for level 1 ...
            <xsl:apply-templates>
                <xsl:template match="operation">
                    before doing something for level 2
                </xsl:template>
            </xsl:apply-templates>
        </xsl:template>
    </xsl:apply-templates>
</xsl:template>

This will match a level 1 operation tag, then all of its child operation
tags, before moving on to the next level 1 tag. However, if you want all
level 1 operation tags to be processed before you match all level 2
operation tags, then do:

<xsl:template match="operation">
    don't do another apply-templates here
</xsl:template>

<xsl:template match="/">
    <xsl:apply-templates select="operation">
    </xsl:apply-templates>

    <xsl:apply-templates select="operation/operation">
    </xsl:apply-templates>
</xsl:template>

Regards,

Mark


> -----Original Message-----
> From: xsl-list@xxxxxxxxx 
> Sent: 24 May 1999 16:00
> To: undisclosed-recipients
> Subject: select nodes only one level with same name
> 
> 
> hi*
> 
> Example of xml:
> 
> <rootnode>
> <operation>
> 	bla-bla-bla...
> 	<operation>
> 		another bla-bla-bla...
> 	</operation>
> 	another bla-bla-bla again
> </operation>
> 
> Example of xsl:
> 
> 
> <xsl:template match="/">                                      
>                        
> bla-bla...
> <xsl:apply-templates select="I want to select first operation node">
> bla-bla-...
> <xsl:apply-templates select="I want to second level operation node">
> </xsl:template>
> 
> How can I do it?
> Thanks.
> Eugeny.
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread