ZVON > Tutorials > XML Schema and Relax NG Tutorial
Index | >> Example 2 / 8 << | Prev | Next |
Contents > Including > Target namespaces are the same (null)

Target namespaces are the same (null)

  1. XML Schema

1. XML Schema

Both target namespaces are the same (null), so inclusion won't have any further effects on the namespace settings in the included schema. Schema Representation Constraint: Inclusion Constraints and Semantics .

Valid document


<root xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
  <x>dhhglh</x>
</root>

Invalid document


<root xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
  <foo:x xmlns:foo="http://foo" >dhhglh</foo:x>
</root>

Correct XML Schema (correct_0.xsd)


<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >

  <xsd:include schemaLocation="correct_1.xsd"/>

  <xsd:element name="root" type="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"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>