This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Searching for an attribute across different elements with ancestoral elements returned


>
> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]