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

Re: XPath: all elements with only non-parent children

Subject: Re: XPath: all elements with only non-parent children with identical style attr
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 12 Dec 2001 12:14:46 +0000
xpath all elements
Hi Tom,

>>Jeni kindly provided me this one:
>>
>>  *[* and
>>     not(*/node()) and
>>     not(*[not(@style)]) and
>>     not(*/@style != */@style)]
>
> maybe a dumb question but why all the "not"s (and writhing and fainting in
> coils?)
> wouldn't 
> *[* and not(*/node()) and (*/@style) and (*/@style = */@style)] 
> work the same way?

Nope. Part of the reason it's like that is that when I gave the
solution to Tobi (offlist) then I went through it bit by bit, so it
just got constructed like that. But partly it's because the way that
XPath logic works it has to be like that.

For example:

  */@style

or:

  *[@style]

is true if *any* of the child elements of the current element have a
style attribute. On the other hand:

  not(*[not(@style)])

is true if *none* of the child elements of the current element do not
have a style attribute. Given the following children:

  <foo style="bar" />
  <foo />

The first will return true, and the second will return false.

Similarly:

  */@style = */@style

is true if *any* of the style attributes of the child elements of the
current element is the same as any other style attribute of the child
elements of the current element. On the other hand:

  not(*/@style != */@style)

is true if *none* of the style attributes of the child elements of the
current element are not the same as any other style attribute of the
child elements of the current element. Given the following children:

  <foo style="bar" />
  <foo style="bar" />
  <foo style="baz" />

The first will return true, and the second will return false.

But you're right that I could combine some of it together - it could
be:

  *[* and
    not(*/node() or
        *[not(@style)] or
        */@style != */@style)]

with the same effect.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.