XML Schema / interactive explanation

elementFormDefault: which namespace is this element in?

A prefix is only a spelling choice. Follow the expanded names to understand why two similar XML documents can validate differently.

Updated2026-09-07
ScopeXSD 1.0 · Namespaces 1.0
Try the example ↓

Read the name the processor sees

An element’s expanded name is the pair namespace URI + local name. This page writes it as {namespace}local. The prefix itself is not part of that identity. Namespaces in XML.

In the experiment, the global record element belongs to urn:xfront:demo. The question is whether its locally declared value child must also belong to that namespace. Keep your eye on the middle name card as you change the controls.

Qualified does not mean visibly prefixed

Start with the inherited default namespace. Switch to the explicit prefix: both expanded element names stay the same and the example still passes. Reset the child’s default namespace instead, and its expanded name changes.

Change one thing. See what breaks.

Look past the angle brackets.

XSD 1.0 · LOCAL
PASS · this example

The local value element has the namespace required by this declaration.

Global record{urn:xfront:demo}record
Local value{urn:xfront:demo}value
Unprefixed attribute{}id · no namespace

01 / Schema

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="urn:xfront:demo"
  elementFormDefault="qualified">
  <xs:element name="record">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="value" type="xs:string"/>
      </xs:sequence>
      <xs:attribute name="id" type="xs:string"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

02 / XML instance

<record xmlns="urn:xfront:demo" id="42">
  <value>hello</value>
</record>

Focused teaching model with complete downloadable examples. No arbitrary schema validation. The default example and comparison table remain readable without JavaScript.

Three names in one small document

NodeNamespace rule
Global record elementUses the schema’s target namespace in this example.
Locally declared value elementFollows elementFormDefault unless its declaration has an overriding form attribute.
Unprefixed id attributeHas no namespace; the document’s default namespace does not apply to its name.

elementFormDefault defaults to unqualified. It does not move global declarations out of the target namespace. Read the W3C qualification examples alongside your actual declarations.

Debug a mismatch from the instance backwards

First identify the exact failing element. Record its namespace URI and local name separately. Inspect the nearest namespace declarations, including an inherited default or a local reset. Looking only for a colon in the tag name is insufficient.

Next find the declaration that governs that element. A reference to a global element is different from a local declaration with the same spelling. Determine which namespace the declaration expects, including any local form override. Then compare the two expanded names character for character.

Finally keep a minimized pair of files. Download the current example and verify it with an XSD 1.0 processor:

xmllint --noout --schema qualification-example.xsd qualification-example.xml

A useful regression test changes only the namespace syntax. One fixture should use a prefix and another a default namespace while preserving identity. A negative fixture should use the same local name in the wrong namespace. That separates meaningful name changes from harmless serialization differences.

In a real integration, check the consumer’s namespace handling too. A validator may accept two equivalent spellings while application code that compares raw tag strings mishandles one. That is a consumer bug rather than a reason to redefine the vocabulary around a preferred prefix.

For architectural namespace choices, continue with zero, one or many namespaces. For declaration scope, use global versus local design. For presence and values, open the nil-value experiment.

Query set / FAQ

Frequently asked questions

01What does elementFormDefault="qualified" mean?

It sets the default qualification of locally declared elements. In a schema with a target namespace, those local elements must be in that namespace unless a local form attribute overrides the default.

02Does qualified mean I must add a prefix?

No. An element can belong to a namespace through an inherited default namespace or an explicit prefix. The expanded name combines the namespace URI with the local name.

03What is the default elementFormDefault value?

The default is unqualified. A global element declaration still belongs to the schema target namespace when one is declared; the setting applies to local element declarations.

04Does the default namespace apply to attributes?

Not to unprefixed attribute names. In the example, id has no namespace even though its owning element inherits a default namespace. Attribute qualification has its own schema settings.

05What does xmlns="" do?

It removes the inherited default namespace for that element and its unprefixed descendant elements until a new default is declared. Explicitly prefixed names still use their prefix bindings.