[xquery-talk] leaf values

Liam Quin liam at w3.org
Sat Feb 11 17:11:54 PST 2006

On Sat, Feb 11, 2006 at 09:02:29AM -0800, fatma helmy wrote:
> Suppose I have the following xml
> <book >
> 	<title>seven years in trenton</title>
> 	<price>12</price>
> </book>
> </bookstore>

(I live near to Trenton, Ontario, for what it's worth)

> suppose also , I have $p which contains the following
> paths book/title , book/price,book/author.

XML Query does not have the concept of putting path
expressions inside variables.

The best you can do in general is to use XSLT or XQuery to
generate the text of a second query which, when run, will
do what you want.

> since title and price are leaves and have values
What if a book title contained further markup?

I am not certain I understand your sample output -- it's
not well-formed XML as I read it, but maybe you have extra
spaces in there..

I think you want,
		for $i in /bookstore/book/price


	{ etc etc }


The question then is how to count the distinct values.  One way
to do that would be to make a list of all the values, and then
to use distinct-values to get a list of the possibilities, and
for each item in that list, count the number of matches in the other.

I haven't written the code for this as I am not sure if that's
what you want -- the bigger question is about using an XPath
expression in a variable, and we don't higher order functionality
right now.


Liam Quin, W3C XML Activity Lead, http://www.w3.org/People/Quin/
http://www.holoweb.net/~liam/  *   http://fromoldbooks.org/

  • Previous message: [xquery-talk] leaf values
  • Next message: [xquery-talk] leaf values
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

  • More information about the talk mailing list