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

Re: $5 PAYPAL for correct answer still not claimed! Se

Subject: Re: $5 PAYPAL for correct answer still not claimed! Searching for an attribute across different elements with ancestoral elements returned
From: "Christopher R. Maden" <crism@xxxxxxxxx>
Date: Fri, 20 Jul 2001 03:37:40 -0700
paypal 5 offer
Please disregard prior... premature send.

At 03:05 20-07-2001, David Glover wrote:
I wish to return all brands/lines/items that have this @OFFER attribute.

This is the confusing part. What do you mean by "return"?


An XPath expression matches nodes. You could have an expression that matches the brands, or, lines, or items, or all of them, but it's not clear what the value of matching all of them would be.

Now, if by "return" you mean "copy into the result tree", i.e. copy the source tree but prune any branches that don't have offers, then what you probably want to do is have a template that matches any BRAND with an offer on any descendant, and then only process the ITEMs with any offers, etc.

<!-- by default, don't copy anything -->
<xsl:template match="BRAND | LINE | ITEM" priority="1"/>

<!-- if there are children with offers, copy this element and then look
     at its children one by one -->
<xsl:template match="BRAND[LINE/@OFFER or LINE/ITEM/@OFFER] |
                     LINE[ITEM/@OFFER]" priority="2">
  <xsl:copy>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

<!-- if this one has the offer, copy it and all its descendants -->
<xsl:template match="BRAND[@OFFER] | LINE[@OFFER] |
                     ITEM[@OFFER]" priority="3">
  <xsl:copy-of select="."/>
</xsl:template>

Based on your example, this should do what you want.

HTH,
Chris
--
Christopher R. Maden, XML Consultant
DTDs/schemas - conversion - ebooks - publishing - Web - B2B - training
<URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4  5DFC AC52 F825 AFEC 58DA


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.