XSpec/XPath error

Having trouble installing Oxygen? Got a bug to report? Post it all here.
scottbdr
Posts: 15
Joined: Tue Jul 21, 2009 1:48 am

XSpec/XPath error

Post by scottbdr »

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
alex_jitianu
Posts: 922
Joined: Wed Nov 16, 2005 11:11 am

Re: XSpec/XPath error

Post by alex_jitianu »

Hello,

At first glance, I can't say I understand either why the error appears. It might help to have a look at the XSLT generated out of the XSpec file. For that:
- click the Configure transformation scenario and edit the Run XSpec Test scenario
- on the Parameters tab set the clean.output.dir parameter to false
- run the scenario
- open and inspect xspec/demo-sch-preprocessed.xsl

I suggest posting an issue on the XSpec GitHub project, as the people maintaining the project have more knowledge about the intermediate steps involved in running a Schematron test.

Best regards,
Alex
HomeGoods
Posts: 96
Joined: Wed Feb 09, 2005 8:57 am

Re: XSpec/XPath error

Post by HomeGoods »

scottbdr wrote: Tue Jun 28, 2022 8:33 pm //status[1] should always return a single value
That expression may return more than a single element, as //status[1] selects all status elements that are the first status children of their respective parents. Take this for example.
scottbdr
Posts: 15
Joined: Tue Jul 21, 2009 1:48 am

Re: XSpec/XPath error

Post by scottbdr »

Thanks HomeGoods. That is exactly what is happening - seems obvious now with your example. The predicate doesn't apply to the whole list of selected status elements, it applies to each context a status element is in.
Post Reply