util:eval and variables

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

util:eval and variables

Andreas Wagner
Hi all,

I am working on a routine that uses util:eval. And I have a case where
simplyfing the string that is being evaluated does fail in a weird way:


let $compareToString :=
($replacementDoc//tei:text//tei:persName[contains(@ref, 'gnd:')][not(ancestor::tei:cit)])[$repeatIndex]/((ancestor::tei:item[ancestor::tei:list/@type = 'dict']|ancestor::tei:p|ancestor::tei:div)/@xml:id/string())[last()]

let $objectExpression1          := "$currentResource//sal:node[@n eq $compareToString]" ||
                                    "/sal:citetrail[1]/text()"

let $objectExpression2          := "$currentResource//sal:node[@n eq ($replacementDoc//tei:text//tei:persName[contains(@ref, 'gnd:')][not(ancestor::tei:cit)])[$repeatIndex]/((ancestor::tei:item[ancestor::tei:list/@type = 'dict']|ancestor::tei:p|ancestor::tei:div)/@xml:id/string())[last()]]" ||
                                    "/sal:citetrail[1]/text()"

return util:eval($objectExpression2)

fails with

exerr:ERROR Error while evaluating expression: $currentResource//sal:node[@n eq ($replacementDoc//tei:text//tei:persName[contains(@ref, 'gnd:')][not(ancestor::tei:cit)])[$repeatIndex]/((ancestor::tei:item[ancestor::tei:list/@type = 'dict']|ancestor::tei:p|ancestor::tei:div)/@xml:id/string())[last()]]/sal:citetrail[1]/text(). XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: range:field($fields as xs:string+, $operators as xs:string+, $keys as xs:anyAtomicType*, ...) node()*. Expected cardinality: one or more, got 0. [at line 170, column 8, source: String]

whereas

return util:eval($objectExpression1)

successfully returns "2.n6.1".

(obviously the content of $compareToString and the string with which @n
is compared in $objectExpression2 are meant to be identical. And I think
they are, aren't they?

This is all in eXide, exist-db  2.2, Build : 20150511.

Any ideas?

TIA,
Andreas


--
Dr. Andreas Wagner                          twitter: @anwagnerdreas
Project "The School of Salamanca"           web: http://salamanca.adwmainz.de
Academy of Sciences and Literature, Mainz   fon: +49 (0)69/798-32774
and Institute of Philosophy                 fax: +49 (0)69/798-32794
Goethe University Frankfurt

IGF HP 25 / R 2.455
Norbert-Wollheim-Platz 1
60629 Frankfurt am Main

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: util:eval and variables

Peter Stadler
Hi Andreas,

yes, I can confirm that those strings are identical ;)
Tow ideas:
* wrap the expression in $objectExpression2 in extra parentheses:  @n eq (($replacementDoc … [last()])]
* switch from using „eq“ to the more generic „=„

Best
Peter

> Am 23.10.2016 um 14:48 schrieb Andreas Wagner <[hidden email]>:
>
> Hi all,
>
> I am working on a routine that uses util:eval. And I have a case where
> simplyfing the string that is being evaluated does fail in a weird way:
>
>
> let $compareToString :=
> ($replacementDoc//tei:text//tei:persName[contains(@ref, 'gnd:')][not(ancestor::tei:cit)])[$repeatIndex]/((ancestor::tei:item[ancestor::tei:list/@type = 'dict']|ancestor::tei:p|ancestor::tei:div)/@xml:id/string())[last()]
>
> let $objectExpression1          := "$currentResource//sal:node[@n eq $compareToString]" ||
>                                    "/sal:citetrail[1]/text()"
>
> let $objectExpression2          := "$currentResource//sal:node[@n eq ($replacementDoc//tei:text//tei:persName[contains(@ref, 'gnd:')][not(ancestor::tei:cit)])[$repeatIndex]/((ancestor::tei:item[ancestor::tei:list/@type = 'dict']|ancestor::tei:p|ancestor::tei:div)/@xml:id/string())[last()]]" ||
>                                    "/sal:citetrail[1]/text()"
>
> return util:eval($objectExpression2)
>
> fails with
>
> exerr:ERROR Error while evaluating expression: $currentResource//sal:node[@n eq ($replacementDoc//tei:text//tei:persName[contains(@ref, 'gnd:')][not(ancestor::tei:cit)])[$repeatIndex]/((ancestor::tei:item[ancestor::tei:list/@type = 'dict']|ancestor::tei:p|ancestor::tei:div)/@xml:id/string())[last()]]/sal:citetrail[1]/text(). XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: range:field($fields as xs:string+, $operators as xs:string+, $keys as xs:anyAtomicType*, ...) node()*. Expected cardinality: one or more, got 0. [at line 170, column 8, source: String]
>
> whereas
>
> return util:eval($objectExpression1)
>
> successfully returns "2.n6.1".
>
> (obviously the content of $compareToString and the string with which @n
> is compared in $objectExpression2 are meant to be identical. And I think
> they are, aren't they?
>
> This is all in eXide, exist-db  2.2, Build : 20150511.
>
> Any ideas?
>
> TIA,
> Andreas
>
>
> --
> Dr. Andreas Wagner                          twitter: @anwagnerdreas
> Project "The School of Salamanca"           web: http://salamanca.adwmainz.de
> Academy of Sciences and Literature, Mainz   fon: +49 (0)69/798-32774
> and Institute of Philosophy                 fax: +49 (0)69/798-32794
> Goethe University Frankfurt
>
> IGF HP 25 / R 2.455
> Norbert-Wollheim-Platz 1
> 60629 Frankfurt am Main
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Exist-open mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/exist-open
--
Peter Stadler
Carl-Maria-von-Weber-Gesamtausgabe
Arbeitsstelle Detmold
Hornsche Str. 39
D-32756 Detmold
Tel. +49 5231 975-676
Fax: +49 5231 975-668
stadler at weber-gesamtausgabe.de
www.weber-gesamtausgabe.de


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open

signature.asc (465 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: util:eval and variables

Andreas Wagner
Hi Peter, hi list,

* Peter Stadler dixit [2016-10-23 20:13]:
> Tow ideas:
> * wrap the expression in $objectExpression2 in extra parentheses:  @n
>   eq (($replacementDoc … [last()])]
> * switch from using „eq“ to the more generic „=„

Neither did change anything. I tried them both individually and
combined, but the error message remained the same. (I also tried to
*additionally* put just ($objectExpression2) in parentheses, but that
did not help either.)

Andreas


>> Am 23.10.2016 um 14:48 schrieb Andreas Wagner
>> <[hidden email]>:
>>
>> let $compareToString :=
>> ($replacementDoc//tei:text//tei:persName[contains(@ref, 'gnd:')][not(ancestor::tei:cit)])[$repeatIndex]/((ancestor::tei:item[ancestor::tei:list/@type = 'dict']|ancestor::tei:p|ancestor::tei:div)/@xml:id/string())[last()]
>>
>> let $objectExpression1          := "$currentResource//sal:node[@n eq $compareToString]" ||
>>                                    "/sal:citetrail[1]/text()"
>>
>> let $objectExpression2          := "$currentResource//sal:node[@n eq ($replacementDoc//tei:text//tei:persName[contains(@ref, 'gnd:')][not(ancestor::tei:cit)])[$repeatIndex]/((ancestor::tei:item[ancestor::tei:list/@type = 'dict']|ancestor::tei:p|ancestor::tei:div)/@xml:id/string())[last()]]" ||
>>                                    "/sal:citetrail[1]/text()"
>>
>> return util:eval($objectExpression2)
>>
>> fails with
>>
>> exerr:ERROR Error while evaluating expression: $currentResource//sal:node[@n eq ($replacementDoc//tei:text//tei:persName[contains(@ref, 'gnd:')][not(ancestor::tei:cit)])[$repeatIndex]/((ancestor::tei:item[ancestor::tei:list/@type = 'dict']|ancestor::tei:p|ancestor::tei:div)/@xml:id/string())[last()]]/sal:citetrail[1]/text(). XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: range:field($fields as xs:string+, $operators as xs:string+, $keys as xs:anyAtomicType*, ...) node()*. Expected cardinality: one or more, got 0. [at line 170, column 8, source: String]
>>
>> whereas
>>
>> return util:eval($objectExpression1)
>>
>> successfully returns "2.n6.1".


--
Dr. Andreas Wagner                          twitter: @anwagnerdreas
Project "The School of Salamanca"           web: http://salamanca.adwmainz.de
Academy of Sciences and Literature, Mainz   fon: +49 (0)69/798-32774
and Institute of Philosophy                 fax: +49 (0)69/798-32794
Goethe University Frankfurt

IGF HP 25 / R 2.455
Norbert-Wollheim-Platz 1
60629 Frankfurt am Main

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: util:eval and variables

Andreas Wagner
In reply to this post by Andreas Wagner
Hi list,

I am sorry to bother you again about this, but does nobody have another idea?

Am 23.10.2016 um 14:48 schrieb Andreas Wagner:

> let $compareToString :=
> ($replacementDoc//tei:text//tei:persName[contains(@ref, 'gnd:')][not(ancestor::tei:cit)])[$repeatIndex]/((ancestor::tei:item[ancestor::tei:list/@type = 'dict']|ancestor::tei:p|ancestor::tei:div)/@xml:id/string())[last()]
>
> let $objectExpression1          := "$currentResource//sal:node[@n eq $compareToString]" ||
>                                     "/sal:citetrail[1]/text()"
>
> let $objectExpression2          := "$currentResource//sal:node[@n eq ($replacementDoc//tei:text//tei:persName[contains(@ref, 'gnd:')][not(ancestor::tei:cit)])[$repeatIndex]/((ancestor::tei:item[ancestor::tei:list/@type = 'dict']|ancestor::tei:p|ancestor::tei:div)/@xml:id/string())[last()]]" ||
>                                     "/sal:citetrail[1]/text()"
>
> return util:eval($objectExpression2)
>
> fails with
>
> exerr:ERROR Error while evaluating expression: $currentResource//sal:node[@n eq ($replacementDoc//tei:text//tei:persName[contains(@ref, 'gnd:')][not(ancestor::tei:cit)])[$repeatIndex]/((ancestor::tei:item[ancestor::tei:list/@type = 'dict']|ancestor::tei:p|ancestor::tei:div)/@xml:id/string())[last()]]/sal:citetrail[1]/text(). XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: range:field($fields as xs:string+, $operators as xs:string+, $keys as xs:anyAtomicType*, ...) node()*. Expected cardinality: one or more, got 0. [at line 170, column 8, source: String]
>
> whereas
>
> return util:eval($objectExpression1)
>
> successfully returns "2.n6.1".

Thanks,

Andreas


--
Dr. Andreas Wagner                          twitter: @anwagnerdreas
Project "The School of Salamanca"           web: http://salamanca.school
Academy of Sciences and Literature, Mainz   fon: +49 (0)69/798-32774
and Institute of Philosophy                 fax: +49 (0)69/798-32794
Goethe University Frankfurt
http://salamanca.adwmainz.de

IGF HP 25 / R 2.455
Norbert-Wollheim-Platz 1
60629 Frankfurt am Main

------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open