[xquery-talk] selection

Michael Kay mhk at mhk.me.uk
Sun Feb 5 23:54:15 PST 2006


> suppose i have this xml file book.xml
> <bookstore>
> <book>
> 	<title>seven years in trenton</title>
> 	<price>12</price>
> 
> </book>
> <book>
> 	<title> history of trenton</title>
> 		<price> 55</price>
> </book>
> </bookstore>
> 
> when I issue the following statement
> let $j:= doc("book.xml")//book [price > 12]
> $j discarded the book with 12 price but my problem is
> that $j now is standing at node book, I want $j to
> discard the book with 12 and stop at bookstore(the
> root)

You can't modify the input document: the original bookstore element will
always contain two books. But you can construct a new bookstore element
containing only one book like this:

let $j := <bookstore> {
     doc("book.xml")//book [price > 12]
} </bookstore>

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




More information about the talk mailing list