ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 3 / 8 << | Prev | Next | |
Because the included schema does not have targetNamespace attribute and the form is "qualified", the target namespace will be "inherited" from the including schema. Schema Representation Constraint: Inclusion Constraints and Semantics, 2.3 .
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:element name="x" minOccurs="1" maxOccurs="1" type="xsd:string" form="qualified"/> </xsd:sequence> </xsd:complexType> </xsd:schema> |
Invalid 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> Valid 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:element name="x" minOccurs="1" maxOccurs="1" type="xsd:string" form="unqualified"/> </xsd:sequence> </xsd:complexType> </xsd:schema> |