To complement this: while not completely made public yet (the next W3
working drafts are to be expected soon), the syntax returned by
fn:path() is actually a valid XPath 3.0 expression; see [1] for more
details.

Christian

[1] http://docs.basex.org/wiki/XQuery_3.0#Expanded_QNames


> --8<---------------cut here---------------start------------->8---
> xquery version "3.0";
>
> declare option output:separator '\n';
>
> declare variable $bad := db:open('Text-DB');
> declare variable $nodes := <nodes><id>499</id><id>713</id></nodes>;
>
> for $id in $nodes//id
>  let $path := replace(db:open-id($bad, $id)/path(), 'Q\{.*?\}', '*:')
>  return $id || ' → ' || xquery:eval('db:node-id(db:open("Text-DB-WS")' || 
> $path || ')')
> --8<---------------cut here---------------end--------------->8---
>
> Apparently the return value from path() is not a valid XPath expression;
> as a workaround I simply replace the "Q{...}" namespace stuff with "*:".
> But I'm not an XQuery hacker, so there's probably a better way...  In
> any case, the above code works on my test database.
>
> HTH and greetings
>
> --
> Dr.-Ing. Michael Piotrowski, M.A. <m...@cl.uzh.ch>
> Institute of Computational Linguistics, University of Zurich
> Phone +41 44 63-54313 | OpenPGP public key ID 0x1614A044
> * OUT NOW: Systems and Frameworks for Computational Morphology
> *          <http://www.springeronline.com/978-3-642-23137-7>
> _______________________________________________
> BaseX-Talk mailing list
> BaseX-Talk@mailman.uni-konstanz.de
> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
_______________________________________________
BaseX-Talk mailing list
BaseX-Talk@mailman.uni-konstanz.de
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk

Reply via email to