[xquery-talk] Can XQuery include the path to a node in
it's answer?
Jason Hunter
jhunter at xquery.com
Sun Nov 28 23:49:34 PST 2004
In Mark Logic you can use xdmp:describe(). The function actually takes
any argument (node, sequence, query object) and outputs a helpful
description. For node types it returns the XPath (including the
appropriate doc() call if any).
http://xqzone.marklogic.com/pubs/2.2/apidocs/Extension.html#describe
The path()/describe() and eval() functions are going to be implemented
by any vendor having to solve problems in the real world. They're just
not standardized.
You could write a portable describe() for node types if you wanted. It
would make a good class lab. Get the document URI, walk the ancestors,
and count the preceding same-named siblings for positional predicates.
-jh-
Michael Kay wrote:
> There is no built-in function that gets the path to a node. (One reason is
> that for any node, there are many paths that reach it).
>
> You'll find some XSLT solutions to this problem, which readily translate to
> equivalent XQuery expressions, at
> http://www.dpawson.co.uk/xsl/sect2/N6077.html
>
> If you're using Saxon, you can use the extension function saxon:path()
>
> Michael Kay
> http://www.saxonica.com/
>
>
>>-----Original Message-----
>>From: talk-bounces at xquery.com
>>[mailto:talk-bounces at xquery.com] On Behalf Of padmapriya ayyagari
>>Sent: 28 November 2004 22:00
>>To: talk at xquery.com
>>Subject: [xquery-talk] Can XQuery include the path to a node
>>in it's answer?
>>
>>Hello,
>>
>>Could someone please tell me how to write an XQuery for getting the
>>values for a given node in the document and also the whole path for
>>that node in the answer to the XQuery?
>>
>>For example,
>>
>>If I say
>>
>>document("abc.xml")/site/catgraph/edge ,
>>
>>then XQuery simply returns the answer but does not include the path
>>/site/catgraph/edge in the answer. Could someone please tell me how to
>>do this?
>>
>>Thanks,
>>Padmapriya
>>_______________________________________________
>>talk at xquery.com
>>http://xquery.com/mailman/listinfo/talk
>>
>
>
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
>
More information about the talk
mailing list