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

Re: Searching for an attribute across different elemen

Subject: Re: Searching for an attribute across different elements with ancestoral elements returned
From: "Rob Lugt" <roblugt@xxxxxxxxx>
Date: Fri, 20 Jul 2001 14:03:51 +0100
Re:  Searching for an attribute across different elemen
>
> I believe you have two simple cases: -
> 1)  If there are children with an OFFER attribute, then copy the current
> element and recurse down the tree
> 2)  If there is an ancestor (or self) with an OFFER attribute then copy
the
> entire branch below that element.
>
> This is simply achieved with the following template:-
>
> <xsl:template match="node()">
>  <xsl:choose>
>   <!-- if there are children with an OFFER attribute, copy node and
recurse
> down the tree -->
>   <xsl:when test="descendant::node()/@OFFER">
>    <xsl:copy>
>     <xsl:copy-of select="@*"/>
>     <xsl:apply-templates/>
>    </xsl:copy>
>   </xsl:when>
>   <!-- if there is an ancestor-or-self with an OFFER attribute, copy
entire
> branch -->
>   <xsl:when test="ancestor-or-self::node()/@OFFER">
>    <xsl:copy-of select="."/>
>   </xsl:when>
>  </xsl:choose>
> </xsl:template>

This can be improved somewhat by replacing the ancestor-or-self::node() test
with "@OFFER", because you never need to test for ancestors with an OFFER
attribute.

Hope this helps some more ;-)

~Rob


 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.