ZVON > Tutorials > XML Schema and Relax NG Tutorial
Index
Contents > elementFormDefault - elements

elementFormDefault - elements

Top-level elements, null namespace

Let us imagine the simplest case. The attribute "elementFormDefault" is useless here, because it has no impact on top-level element definitions. ( 3.3.2 XML Representation of Element Declaration Schema Components ).

The attribute "elementFormDefault" is useless here, so the result is the same as above.

...
Top-level elements, non-null namespace

Again, it does not make a difference, whether we use "qualified" or "unqualified" value. 3.3.2 XML Representation of Element Declaration Schema Components . Because these elements are top-level (they have "schema" as a parent), they must be from the "targetNamespace".

The value of the "elementFormDefault" does not play any role, explanation see above.

...
elementFormDefault unqualified for not-top-level elements, namespace non-null

Now let's have a child element. Because the attribute "elementFormDefault" is set to "unqualified", the child must be from the null namespace.

We can set the namespace using the "ns" attribute. Here the "name" element does not have "ns" attribute, and thus it is inherited from nearest ancestor (which has "ns" attribute).

...
elementFormDefault qualified for not-top-level elements, namespace non-null

Because the attribute "elementFormDefault" is set to "qualified", the child must be from the namespace "http://foo" (from the "targetNamespace").

We can set the namespace for all elements using the "ns" attribute. The value is inherited and now all elements must be from the "http://foo" namespace.

...