ZVON > Tutorials > XML Schema and Relax NG Tutorial
Index | >> Example 3 / 3 << | Prev | Next |
Contents > The namespace of document root element > The namespace of the document root element does not match the targetNamespace

The namespace of the document root element does not match the targetNamespace

  1. XML Schema
XML Schema keys: targetNamespace
Relax NG keys: ns

1. XML Schema

When the namespace of the root element does not match the targetNamespace, it's an error (well, I think). I would compare this to having no "matching" rules in XSLT. See ( 3.3.4 Element Declaration Validation Rules Validation Rule: Element Locally Valid (Element): no. 1 ). We can't say what's wrong - whether the schema or the document.

Invalid document


<f:root xsi:schemaLocation="http://foo incorrect_0.xsd" xmlns:f="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > test </f:root>

Incorrect XML Schema (incorrect_0.xsd)


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

  <xsd:element name="root" type="xsd:string"/>
</xsd:schema>