How to use function matches in schematron?

This should cover W3C XML Schema, Relax NG and DTD related problems.
Posts: 1
Joined: Wed Jan 04, 2012 4:13 pm

How to use function matches in schematron?

Post by sabine84 » Wed Jan 04, 2012 4:53 pm


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

Posts: 2696
Joined: Tue May 17, 2005 4:01 pm

Re: How to use function matches in schematron?

Post by adrian » Fri Jan 06, 2012 12:45 pm


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">
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger

Post Reply