ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 6 / 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:anyAtribute" elements. In this example, the included schema allows one arbitrary attribute from namespace other than target namespace, so after inclusion, the "##other" will forbid attributes from both null-namespace and "http://foo" namespace. Schema Representation Constraint: Inclusion Constraints and Semantics, 3.2.2 .
Valid document <foo:root xsi:schemaLocation="http://foo correct_0.xsd" bar:x="1" xmlns:foo="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bar="http://bar" /> Invalid document <foo:root xsi:schemaLocation="http://foo correct_0.xsd" x="1" xmlns:foo="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> Invalid document <foo:root xsi:schemaLocation="http://foo correct_0.xsd" foo:x="1" xmlns:foo="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> |
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:anyAttribute namespace="##other" processContents="skip"/> </xsd:complexType> </xsd:schema> |