P
patrik.nyman
I have a modular set of xml schemas that are being <include/>d
into a master schema. The modules have no target namespace,
but `inherit' the namespace of the master schema -- this is
the so called Chameleon design. The master schema in its turn
is <import/>ed into other schemas with different namespaces.
Now, in the modules I'd like to use Schematron rules. Problem
is, these do not seem to inherit the target namespace of the
master schema. The way out is to define the context namespace
in the Schematron rules themselves with for example
<sch:ns uri="http://www.kb.se" prefix="kb"/>.
But, this goes counter against the idea with the Chameleon design.
So my question is, is there a way for the Schematron rules to
inherit the target namespace of the including schema?
(Hope this is clear.)
Below are sample code snippets.
kb-names.xsd:
---------------------------->%--------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns:sch="http://www.ascc.net/xml/schematron">
<xs:complexType name="type.person" mixed="true">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:group ref="group.personElements"/>
</xs:sequence>
</xs:complexType>
<xs:element name="person" type="type.person">
<xs:annotation>
<xs:appinfo>
<schattern name="Test">
<sch:rule context="person">
<sch:assert test="count(persName) > 1">
You can have only one persName element within a person
element.
</sch:assert>
</sch:rule>
</schattern>
</xs:appinfo>
</xs:annotation>
</xs:element>
<!-- ... -->
</xs:schema>
---------------------------->%--------------------------
kb.xsd:
---------------------------->%--------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns:sch="http://www.ascc.net/xml/schematron"
targetNamespace="http://www.kb.se"
xmlns:kb="http://www.kb.se">
<xs:include schemaLocation="kb-names.xsd"/>
<xs:include schemaLocation="kb-identifiers.xsd"/>
<!-- ... -->
</xs:schema>
---------------------------->%--------------------------
Thanks,
/Patrik Nyman
into a master schema. The modules have no target namespace,
but `inherit' the namespace of the master schema -- this is
the so called Chameleon design. The master schema in its turn
is <import/>ed into other schemas with different namespaces.
Now, in the modules I'd like to use Schematron rules. Problem
is, these do not seem to inherit the target namespace of the
master schema. The way out is to define the context namespace
in the Schematron rules themselves with for example
<sch:ns uri="http://www.kb.se" prefix="kb"/>.
But, this goes counter against the idea with the Chameleon design.
So my question is, is there a way for the Schematron rules to
inherit the target namespace of the including schema?
(Hope this is clear.)
Below are sample code snippets.
kb-names.xsd:
---------------------------->%--------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns:sch="http://www.ascc.net/xml/schematron">
<xs:complexType name="type.person" mixed="true">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:group ref="group.personElements"/>
</xs:sequence>
</xs:complexType>
<xs:element name="person" type="type.person">
<xs:annotation>
<xs:appinfo>
<schattern name="Test">
<sch:rule context="person">
<sch:assert test="count(persName) > 1">
You can have only one persName element within a person
element.
</sch:assert>
</sch:rule>
</schattern>
</xs:appinfo>
</xs:annotation>
</xs:element>
<!-- ... -->
</xs:schema>
---------------------------->%--------------------------
kb.xsd:
---------------------------->%--------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns:sch="http://www.ascc.net/xml/schematron"
targetNamespace="http://www.kb.se"
xmlns:kb="http://www.kb.se">
<xs:include schemaLocation="kb-names.xsd"/>
<xs:include schemaLocation="kb-identifiers.xsd"/>
<!-- ... -->
</xs:schema>
---------------------------->%--------------------------
Thanks,
/Patrik Nyman