[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Seeking combinatorial XPATH
Subject: Re: [xsl] Seeking combinatorial XPATH From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Wed, 7 Mar 2001 09:08:08 +0000 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Seeking combinatorial XPATH, Paul Bell | Thread | [xsl] Converting non-numeric charac, Scott Downie |
[xsl] Re: paging question, Dimitre Novatchev | Date | Re: [xsl] <xsl:sort> using a derive, Jeni Tennison |
Month |