ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 5 / 8 << | Prev | Next | |
When the target namespace of the included schema is null, it is changed to the target namespace of the including document. This process includes also the wildcards: "xsd:any" elements. In this example, the included schema allows one arbitrary element from target namespace, so after inclusion, the "##targetNamespace" will stand for "http://foo", not for null-namespace. Schema Representation Constraint: Inclusion Constraints and Semantics, 3.2.2 .
Valid document <foo:root xsi:schemaLocation="http://foo correct_0.xsd" xmlns:foo="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <foo:x>dhhglh</foo:x> </foo:root> Invalid document <foo:root xsi:schemaLocation="http://foo correct_0.xsd" xmlns:foo="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <x xmlns="">dhhglh</x> </foo:root> |
Correct XML Schema (correct_0.xsd) <xsd:schema targetNamespace="http://foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:foo="http://foo" > <xsd:include schemaLocation="correct_1.xsd"/> <xsd:element name="root" type="foo:myType"/> </xsd:schema> Correct XML Schema (correct_1.xsd) <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd:complexType name="myType"> <xsd:sequence> <xsd:any namespace="##targetNamespace" minOccurs="1" maxOccurs="1" processContents="skip"/> </xsd:sequence> </xsd:complexType> </xsd:schema> |