XSpec/XPath error
Posted: Tue Jun 28, 2022 8:33 pm
Hi, I'm getting a curious error when I run an Schematron XSpec script I have. It's basically complaining about a variable passing a sequence to a function (either lower-case() or matches()) and the use of a predicate [1] to select a single value doesn't seem to solve the problem. When I remove the possibility of a multiple value return from the XSpec context the problem goes away. Fortunately the XSpec context with multiples of the element is a contrived test scenario I would never see in production, however I'm curious about why this is happening.
The Schematron variable causing the problem is this (bold face is the problematic expression):
<sch:let name="REG_ALLOWED_STATUS_VALS" value="
if(lower-case(//status[1]/normalize-space()) = ('production','sample'))
then ('stable','deprecated') else ('unstable','stable','deprecated')" />
The element 'status' is actually allowed only once in tested document however if I have a XSpec context that contains two, I get this in the ANT [Run XSpec Test] result tab:
"A sequence of more than one item is not allowed as the first argument of fn:lower-case() . Found while atomizing the second operand of '='"
It seems like //status[1] should always return a single value, and thus not trigger this error - am I mistaken about that? Just wondering if I'm missing something simple here or if you have any thoughts.
Thanks, Scott
The Schematron variable causing the problem is this (bold face is the problematic expression):
<sch:let name="REG_ALLOWED_STATUS_VALS" value="
if(lower-case(//status[1]/normalize-space()) = ('production','sample'))
then ('stable','deprecated') else ('unstable','stable','deprecated')" />
The element 'status' is actually allowed only once in tested document however if I have a XSpec context that contains two, I get this in the ANT [Run XSpec Test] result tab:
"A sequence of more than one item is not allowed as the first argument of fn:lower-case() . Found while atomizing the second operand of '='"
It seems like //status[1] should always return a single value, and thus not trigger this error - am I mistaken about that? Just wondering if I'm missing something simple here or if you have any thoughts.
Thanks, Scott