schema aware schematron in xsd
Posted: Mon Mar 02, 2015 9:37 am
Hi,
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:
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.)
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
<xs:schema
xmlns:xs = "http://www.w3.org/2001/XMLSchema"
xmlns:sch = "http://purl.oclc.org/dsdl/schematron"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo>
<xsl:import-schema schema-location="Schema.xsd"/>
</xs:appinfo>
</xs:annotation>
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="digits" type="digitsType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="digitsType">
<xs:annotation>
<xs:appinfo>
<sch:pattern>
<!--<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)
</sch:assert>
</sch:rule>
</sch:pattern>
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:schema>