XML Schema: Use elementFormDefault to Hide/Expose Namespaces
Use elementFormDefault to Hide/Expose Namespaces
* 'elementFormDefault' is a binary switch attribute in the schema to control if the origin (i.e. namespace) of each element should be
- hidden (elementFormDefault="unqualified")
- or exposed ("elementFormDefault="qualified").
* elementFormDefault defaults to "unqualified"
* All schemas must have a consistent value for 'elementFormDefault' in order to hide/expose all elements.
Hide Namespaces
* Advantages:
- Simplicity
- Flexibility to change the schema without impact of instance documents.
* Howto:
- Set elementFormDefault="unqualified" in all schemas.
- The element must not be globally declared.
Best Practices
* Make two identical copies of a schema:
- One with elementFormDefault="qualified"
- One with elementFormDefault="unqualified"
* Minimize the use of global elements and attributes.
Notes
* Global elements and attribute must always be qualified.
* Use <include> to include schema with same namespace.
* Use <import> to include schema with different namespace.
References
* Hide (Localize) Namespaces Versus Expose Namespaces or PDF version