Page 1 of 1

How to use function matches in schematron?

Posted: Wed Jan 04, 2012 4:53 pm
by sabine84

Can anybody help me? I want to use regular expressions in my schematron.

here my xml:

here my schematron:
<rule context="//External_reference[Document_type='KAB']">
<assert test="matches(Document_number, '^.{19}EL[V|X]')">
Achtung! </assert>

Is there a problem with the function "matches"?

I also for ...886_016... only numbers are allowed.

king regards

Re: How to use function matches in schematron?

Posted: Fri Jan 06, 2012 12:45 pm
by adrian

The problem is that the function matches is from XSLT/XPath 2.0 which is not enabled by default in Schematron.

If you are using Schematron 1.5(namespace you need to activate an option in Oxygen:
Options -> Preferences, XML -> XML Parser, Schematron XPath Version: 2.0

If you are using ISO Schematron(namespace you have to add an attribute on the schema root: queryBinding="xslt2"

Code: Select all

<schema xmlns="" queryBinding="xslt2">