Subject: Re: [xsl] 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 |
> > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Searching for an attribut, Rob Lugt | Thread | Re: [xsl] $5 PAYPAL for correct ans, Christopher R. Maden |
RE: [xsl] whitespace, Crowers, Steve | Date | Re: [xsl] Bold Text, Lawrence Mielniczuk |
Month |