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: $5 PAYPAL for correct answer still not claimed! Searching for an attribute across different elements with ancestoral elements returned


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.

<xsl:template match="BRAND[@OFFER]" priority="1">

>If it is an ITEM I wish to return its parent LINE and grandparent BRAND as
>well.  If it is a LINE, I wish to return its child ITEMs and parent BRAND as
>well.  If it is BRAND I wish it to return its child LINEs and its
>grandchildren ITEMs. I DO NOT WANT any siblings of the matched element.
>
>I've tried the following 2 patterns :
>
>//BRAND/LINE[@OFFER] | //BRAND/LINE[ITEM[@OFFER]] |
>//BRAND/LINE[ITEM[@OFFER]]
>The problem with this was, that siblings were returned.
>
>//*[@OFFER]
>The problem with this was it failed to return parents of the matched items.
>
>Given the above example XML and the correct XPATH expression I'm looking for
>the following returned XML :
><BRAND>
>         <LINE ID="1">
>                 <ITEM OFFER="BUYXGET1FREE"/>
>         </LINE>
>         <LINE ID="3" OFFER="BUYXGET1FREE">
>                 <ITEM/>
>                 <ITEM/>
>                 <ITEM/>
>                 <ITEM/>
>         </LINE>
></BRAND>
>
>Payment to the 1st geezer with the RIGHT answer.
>ENTERNALLY greatful for any help offered! :)
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

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


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