Page 1 of 1

schema aware schematron in xsd

Posted: Mon Mar 02, 2015 9:37 am
by Patrik

I have added soem schematron rules within my xsd. Now with growing complexity it appears that I use the same element name twice and it might happen that a schematron rules matches the second element as well which it shouldn't. Now my idea is to use schema-element or element(*, myType) as pattern to ensure I match only the specific element.

Of course this requires an xsl:import-schema and i made it work within a schematron file. However, I can't get it work with xsd embedded scheamtron. I keep getting the message
XPST0008 XSLT Pattern syntax error at char 11 on line 26 in {element(*, digitsType)}: No schema has been imported for namespace ''

my test schema looks like this:

Code: Select all

xmlns:xs = ""
xmlns:sch = ""
xmlns:xsl = ""

<xsl:import-schema schema-location="Schema.xsd"/>

<xs:element name="root">
<xs:element name="digits" type="digitsType" maxOccurs="unbounded"/>

<xs:simpleType name="digitsType">
<!--<sch:rule context="digits">-->
<sch:rule context="element(*, digitsType)">
<sch:assert test="matches(text(), '^[0-9]+$')">
The <sch:value-of select="name()"/>-element must contain only digits. (xsd)
<xs:restriction base="xs:string"/>

I guess when extracting the schematron code from the xsd it only considers sch:pattern and simply ignores the xsl:import-schema. Is there any way to make this work? (I already tried to use sch:include but this seems to be ignored as well.)

Re: schema aware schematron in xsd

Posted: Sun Mar 29, 2015 11:18 am
by Patrik
I managed to make it work by modifying the schematron xslt scripts. If someone is interested I'd gladly share the code. (Some more modifications were neccessary.)

It might as well me a nice feature to add "schema aware" as a schematron configuration parameter to oxygen.


Re: schema aware schematron in xsd

Posted: Thu Apr 02, 2015 4:49 pm
by george
Hi Patrick,

I think this comes down to copying the embedded XSLT together with the embedded Schematron when the Schematron rules are extracted from the XSD or Relax NG schema.
We plan to support this as well - but it will work only if allowForeign is set to true, otherwise the foreign elements (other than Schematron) will be discarded when the Schematron schema is converted to XSLT.

Best Regards,