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

Re: Checking a parent's attribute

Subject: Re: Checking a parent's attribute
From: Nicholas Orr <nick@xxxxxxxxxxx>
Date: Wed, 7 Feb 2007 22:36:16 +1100
Re:  Checking a parent's attribute
On 07/02/2007, at 9:09 PM, Abel Braaksma wrote:

Depending on your needs, it may be better suited to use template matching instead of for-each. For instance, the above for-each can be written in separate templates like this (first one is your initial template):

<xsl:template match="/">
<xsl:apply-templates select="ExportEntries[../Restore/ @state='True']" />
</xsl:template>


<xsl:template match="ExportEntries">
   ... do something on ExportEntry level ....
   <xsl:apply-templates select="ExportEntry/Field" />
</xsl:template>

<xsl:template match="Field">
    .... do something on field level ....
   ... this is the same as the core of your for-each ...
</xsl:template>

Thanks Abel. In my case I only need to get to the end result, so I'm presuming I could just use :


<xsl:template match="ExportEntries[../Restore/@state='True']/ ExportEntry/Field" />
...
</xsl:template>


Would that be any different than the for each :

<xsl:for-each select="ExportEntries[../Restore/@state='True']/ ExportEntry/Field">
...
</xsl:for-each>


I haven't explored templates yet, so I'll have to read up them. Just to note, the ExportEntries node is buried deep in the tree, it's not above the root, so I'm not sure that makes a difference.

Thanks,
Nick

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.