|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








