ZVON > Tutorials > XML Schema and Relax NG Tutorial
Index
Contents > The namespace of document root element

The namespace of document root element

The document root element is from null namespace

If we use the attribute "noNamespaceSchemaLocation", we say that the schema is for element from null namespace.

See, how easily this can be accomplished using Relax NG. The pattern <name ns="">root</name> says, that the root element must be named "root" and that it must be from null namespace.

...
The document root element is from some particular namespace

If we use the attribute "schemaLocation", we say that the schema is for element from some particular namespace. In schema, you need to use the "targetNamespace" attribute, which defines the namespace, from which the element must be.

See, how easily this can be accomplished using Relax NG. The pattern <name ns="http://foo">root</name> says, that the root element must be named "root" and that it must be from the namespace "http://foo".

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

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.

...