This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Seeking combinatorial XPATH
- To: "Paul Bell" <pbell at syncsort dot com>
- Subject: Re: [xsl] Seeking combinatorial XPATH
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Wed, 7 Mar 2001 09:08:08 +0000
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <009e01c0a671$bb5c2f70$89ef3ec6@entilzah>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Paul,
I think that you want:
* any A element such that
either
* the string value of its child B element
* whose num attribute equals 'case1'
equals
* the string value of the B element
* that is a child of any A element
and
* whose num attribute equals 'case3'
or
* the string value of its child B element
* whose num attribute equals 'case3'
equals
* the string value of the B element
* that is a child of any A element
and
* whose num attribute equals 'case1'
This translates as:
A[B[@num = 'case1'] = /ROOT/A/B[@num = 'case3'] or
B[@num = 'case3'] = /ROOT/A/B[@num = 'case1']]
You may find it handy to store the A elements in keys based on the
value of their B children (with the different @nums):
<xsl:key name="case1" match="A" use="B[@num = 'case1']" />
<xsl:key name="case3" match="A" use="B[@num = 'case3']" />
With these definitions you can retrieve all the A elements whose B
child (with a num attribute equals to 'case1') equals 'abc' with:
key('case1', 'abc')
If none are retrieved from the key, then there aren't any A elements
with the relevent B child with that value and the expression will
evaluate to false in a boolean context. So, you can change the
expression to:
A[key('case3', B[@num = 'case1']) or
key('case1', B[@num = 'case3'])]
[Note: You hardly ever want to use the text() node test to get text
nodes - more often than not, you want the string value of the node
instead, which you can just get by selecting the node itself.]
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list