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

Re: UNIQUE List of nodes attributes that have a partic

Subject: Re: UNIQUE List of nodes attributes that have a particular value
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Sun, 20 Apr 2003 13:31:34 +0200
nodes.attributes
A single XPath 1.0 expression selecting what you want is not possible in the
general case.

However, if every element has a single attribute and if the elements are
sorted by the names of their attributes, then the following expressions do
what you need:

/*/*/@*[. = 'foo'][not(name() = name(../preceding-sibling::*[@*=
'foo'][1]/@*))]

selects

  <NodeA name="foo"/>
  <NodeB author="foo"/>
  <NodeC reporter="foo"/>


and

/*/*/@*[. = 'larry'][not(name() = name(../preceding-sibling::*[@*=
'larry'][1]/@*))]

selects

  <NodeA name="larry"/>
  <NodeB author="larry"/>



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


"Larry Hayashi" <larry_hayashi@xxxxxxxxxxx> wrote in message
news:Law15-F28cvIhkeTxtf00001e0c@xxxxxxxxxxxxxx
> I am trying to find all the attributes in an XML document that contain a
> particular value.
>
> Given the following data...
>
> <ExampleData>
> <NodeA name="foo"/>
> <NodeA name="larry"/>
> <NodeA name="foo"/>
> <NodeB author="foo"/>
> <NodeB author="larry"/>
> <NodeC reporter="foo"/>
> </ExampleData>
>
> I would like to write an XPATH statement that returns this:
>
> <NodeA name="foo"/>
> <NodeB author="foo"/>
> <NodeC reporter="foo"/>
>
> Note that I am only returning UNIQUE instances of element/attribute
> combinations with the attribute value.
>
> Is this possible using XPATH?
>
> Thanks!
>
> Larry
>
> _________________________________________________________________
> Help STOP SPAM with the new MSN 8 and get 2 months FREE*
> http://join.msn.com/?page=features/junkmail
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>




 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.