Thursday, August 8, 2013

Issue when using xquery external variables from the command line in BaseX

Issue when using xquery external variables from the command line in BaseX

I have the following query in a XQ file named "consulta.xq"
declare namespace xs = "http://www.w3.org/2001/XMLSchema";
declare variable $word as xs:string+ external;
for $entry in doc("cni_es_cushimariano2008")//e
where $entry//l[matches(., $word)]
return <e>{$entry//r//text()} --> {$entry//l//text()}</e>
My database "cni_es_cushimariano2008" has the following structure/data:
<?xml version="1.0" encoding="UTF-8"?>
<dictionary>
<alphabet>aeiobchjmnñprsty</alphabet>
<section id="main" type="standard">
<!-- cuidarse (de alguien). aamaantsi. -->
<e>
<p>
<l>cuidarse (de alguien)</l>
<r>aamaantsi<s n="verbo intransitivo"/>
<s n="infinitivo"/>
</r>
</p>
</e>
<!-- celoso. aamaantsi. -->
<e>
<p>
<l>celoso</l>
<r>aamaantsi<s n="adjetivo"/>
</r>
</p>
</e>
<!-- traer. aamaantsi. -->
<e>
<p>
<l>traer</l>
<r>aamaantsi<s n="verbo transitivo"/>
<s n="infinitivo"/>
</r>
</p>
</e>
</section>
</dictionary>
I am trying to execute the following command line instruction
$ basex -b$word=celoso consulta.xq
but I don't receive the expected result and receive the following message:
[XPDY0002] No value assigned to $word as xs:string+.
I am not an expert using Basex and XQuery so I will be grateful for any
answer that might help me. Thanks in advance.

No comments:

Post a Comment