Re: Query on the XML graph

Murali Mani <[email protected]>
Newsgroups gmane.comp.web.query-languages
Message-ID <[email protected]>

> For example, given a structure containing Employee elements with ID and
> ReportsTo attributes (typed as ID, IDREF, respectively), here are some joins
> expressed using XPath 1.0:
>
> (: all managers - i.e., all employees with at least one direct report :)
> //Employee[//Employee/@ReportsTo = @ID]

can I write the above query as also:
Id(//Employee/@ReportsTo)

by semantics of duplicate elimination, they will give the same result?

> If XPath had an idref() function, you could do something like: :)
> //Employee[count(idref(@ID)) >= 2]

I thought there was an idref function?
http://www.w3.org/TR/xquery-operators/#func-idref

> //Employee[count(.//Employee)]
> (: is trivial, but there's no way to recursively follow ID/IDREF edges :)

I will tentatively suggest this:

I think there should be step/(s) to navigate id/idref. Reasons are:

1. Now how do you traverse 2 idref edges in one path expression; it is not
very easy..

rough example: manager of managers:
Id(Id(//Employee/@ReportsTo)/@ReportsTo)

I think rather than the above, something like:

//Employee/@ReportsTo->Employee/@ReportsTo->Employee might be easier to
understand..??

2. We can think of extending recursive operators to idref traversal, and
say:

rough example: (This query can be written w/o recursion; but we can think
of transitive closure as something like this..??)
//Employee/(@ReportsTo->Employee)*

best, murali.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.