This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XPath: all elements with only non-parent children with identical style attr
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: TSchutzerWeissmann at uk dot imshealth dot com
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 12 Dec 2001 12:14:46 +0000
- Subject: Re: [xsl] XPath: all elements with only non-parent children with identical style attr
- Organization: Jeni Tennison Consulting Ltd
- References: <9723092BA4DBD111816D0000F6B093610A3A32EB@imsuklndsx1.lnd.uk.imshealth.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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