How can I use XML namespaces to combine documents that use different element type and attribute names?
Before we answer this question, we need to clear up a common misconception about XML namespaces. It is often believed that XML namespaces provide some sort of magic that allows you to automatically combine XML documents that use separate sets of element types and attributes. This is not true. Although XML namespaces provide some of the tools you need to do this, you still need to do most of the work yourself, as you will see in the answer to this question. To combine documents that use separate sets of element types and attributes, all you really need to do is decide where the elements and attributes go in the final document. For example, does element type A from the first document go inside element type B? Is it a sibling? Or are they completely unrelated? Although the procedure for actually combining two documents can be easily automated, deciding how to combine them is not likely to ever be automated. Instead, it is a strictly human problem, requiring somebody to make choices.
Related Questions
- Can the content model in an element type declaration contain element types whose names come from other XML namespaces?
- How can I use XML namespaces to combine documents that use different element type and attribute names?
- How do I use prefixes to refer to element type and attribute names in an XML namespace?