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

Friday, 9 August 2013 · 2 messages
RM
Richard Alexander Castro Mamani9 Aug 2013 03:01 #
Hello,
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.
Best regards, Richard.
-- Richard Alexander Castro Mamani http://unsaac.academia.edu/RichardAlexanderCastroMamaniGrupo de Investigación Hinantin - UNSAAC Docente de Educación Primaria - ISPP "Uriel Garcia" de Cusco skype: richardtk_1 E-mail: rcastro at hinantin.com http://hinantin.unsaac.edu.pe
DK
Dirk Kirsten9 Aug 2013 03:32 #
Hi Richard, You have to escape the $ sign, otherwise the shell will interpret it. You can solve this problem by using \$ (i.e. execute basex -b\$word=celoso consulta.xq) or you can also simply completely drop the $ sign - It is not required for passing an external variable. Cheers, Dirk
Quoted text · Richard Alexander Castro Mamani · 61 lines
On 08/09/2013 03:01 AM, Richard Alexander Castro Mamani wrote: > Hello, > 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. > Best regards, Richard. > > > -- > Richard Alexander Castro Mamani > http://unsaac.academia.edu/RichardAlexanderCastroMamaniGrupo de Investigación Hinantin - UNSAAC > Docente de Educación Primaria - ISPP "Uriel Garcia" de Cusco > skype: richardtk_1 > E-mail: rcastro at hinantin.com > http://hinantin.unsaac.edu.pe > > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
-- Dirk Kirsten, BaseX GmbH, http://basex.org |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22

⚡Generated with XQuery