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

Re: Seeking combinatorial XPATH

Subject: Re: Seeking combinatorial XPATH
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 7 Mar 2001 09:08:08 +0000
xpath attribute equals
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


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.