Re: Seeking combinatorial XPATH
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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format