|
Subject: Re: [xsl] 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 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] XPath: all elements with , TSchutzerWeissmann | Thread | [xsl] Keep it simple S..., Mike Ferrando |
| RE: [xsl] Dumb questions from a new, Steve Renshaw | Date | RE: [xsl] Dumb questions from a new, Mike Ferrando |
| Month |