xsl-list
[Top] [All Lists]

RE: [xsl] Need help OR'ing in XPATH.

2006-03-22 02:14:07
Juts translate your English into XPath directly...

For my contrived example below, I would like to select

select="

all book nodes 

book

whose

[

owner is "aaa"

owner='aaa'

*or*

or

which have a chapter whose owner is 
"aaa",

chapter/owner='aaa']"

Putting that together:

select="book[owner is "aaa" or chapter/owner='aaa']

ALternatively you could write

select="book[owner is "aaa"] | book[chapter/owner='aaa']

The "|" operator here forms the union of two sets.

In both cases the results will be in document order, as required.

Michael Kay
http://www.saxonica.com/


 and 
I would like the books to be retrieved in the same general 
order as the 
xml document, i.e., the query for the example below would 
process books 
with id's 1, 3, 4 (in that order), not 1, 4, 3.

I can do the XPATH for *either* of the two cases, but don't 
know how to 
combine the two for an OR search in my xsl:apply-templates 
select statement.

<xsl:a-t select="book[owner='aaa'] or book/chapter[owner='aaa']"/>

is kind of what I want, but Xalan is complaining that my select 
attribute is just returning a boolean, so my syntax is 
apparently wrong.

Any help would be much appreciated.

Thanks,
Glen


<book id="1">
     <owner>aaa</owner>
     <chapter>
         <owner>bbb</owner>
     </chapter>
     <chapter>
         <owner>ccc</owner>
     </chapter>
</book>
<book id="2">
     <owner>bbb</owner>
     <chapter>
         <owner>bbb</owner>
     </chapter>
     <chapter>
         <owner>ccc</owner>
     </chapter>
</book>
<book id="3">
     <owner>ccc</owner>
     <chapter>
         <owner>aaa</owner>
     </chapter>
     <chapter>
         <owner>ccc</owner>
     </chapter>
</book>
<book id="4">
     <owner>aaa</owner>
     <chapter>
         <owner>bbb</owner>
     </chapter>
     <chapter>
         <owner>ccc</owner>
     </chapter>
</book>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--