How to use function matches in schematron?

This should cover W3C XML Schema, Relax NG and DTD related problems.
sabine84
Posts: 1

How to use function matches in schematron?

Wed Jan 04, 2012 4:53 pm

Hello!

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

here my xml:
<kbl:KBL_container>
<External_reference>
<Document_type>KAB</Document_type>
<Document_number>TAB_886_016_JK_KPR_ELV_____300611</Document_number>
</External_reference>
</kbl:KBL_container>

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

Is there a problem with the function "matches"?

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


king regards
adrian
Posts: 2337

Re: How to use function matches in schematron?

Fri Jan 06, 2012 12:45 pm

Hello,

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 http://www.ascc.net/xml/schematron) 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 http://purl.oclc.org/dsdl/schematron) you have to add an attribute on the schema root: queryBinding="xslt2"
e.g.

Code: Select all

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


Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 0 guests