Page 1 of 1

Schematron -- embedded vs separate schema

Posted: Thu Dec 03, 2009 9:40 pm
by perry
In the 10.3 user manual, section "Validating XML documents against a schema", it says:
Validation of an XML document against a W3C XML Schema or Relax NG Schema with embedded ISO Schematron rules allows XPath 2.0 in the expressions of the ISO Schematron rules. This ensures that both XPath 1.0 and XPath 2.0 expressions are accepted in the embedded ISO Schematron rules and are enforced by the validation operation. For embedded Schematron 1.5 rules the version of XPath is set with a user preference.
This implies that XPath 2.0 is fine in embedded schematron schemas, but that XPath 2.0 isn't allowed when the schematron schema is in a separate file. Is this correct?

I'm attempting to use a separate ISO schematron schema, associated with the document using

Code: Select all

<?oxygen SCHSchema="mei.sch"?>
. However, I get an error:

Code: Select all

Error in expression count(distinct-values(descendant::staffdef/@n)): Unknown system function: distinct-values
even though the very same rules don't produce this error when the schematron is embedded in the RelaxNG schema.

The offending schematron rule is:

Code: Select all

<rule context="staffgrp">
<let name="countstaves" value="count(descendant::staffdef)"/>
<let name="countuniqstaves"
value="count(distinct-values(descendant::staffdef/@n))"/>
<assert test="$countstaves eq $countuniqstaves"> When defining
staffgrp(s),each staffdef must have a unique @n value. </assert>
</rule>
Any help greatly appreciated,

--
perry

Re: Schematron -- embedded vs separate schema

Posted: Fri Dec 04, 2009 1:23 pm
by george
Hi,

If you have an ISO Schematron schema then you can control the XSLT/XPath level with the queryBinding attribute. If you want XSLT/XPath 2.0 then use queryBinding="xslt2":

Code: Select all

<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">

...
</sch:schema>
Best Regards,
George

Re: Schematron -- embedded vs separate schema

Posted: Fri Dec 04, 2009 4:08 pm
by perry
Thank you, George. You've made my day!

Best wishes,

--
perry