-
Notifications
You must be signed in to change notification settings - Fork 7
5: XML Namespaces
Namespaces are a way to avoid tag conflicts in XML data files that support more than one source for their tags.
The NAACCR XML standard defines a set of tags (NaaccrData, Patient, Tumor) and attributes that fall under the following namespace:
http://naaccr.org/naaccrxml
To be valid according to the specifications, both data files and dictionaries must define that default namespace as a root attribute like this:
xmlns="http://naaccr.org/naaccrxml"
Since namespaces are an advanced feature of XML, not all software creating XML data files might follow that convention. For that reason, the library has an option that allows it to run in a "relaxed" namespace mode. In that mode, it is OK to not specify the default namespace (it is assumed if not present).
The standard allows non-standard attributes to appear in the root tag of the data files but those need to be defined in their own namespace. Here is an example of a root attribute defining an extra namespace for the prefix "ext":
xmlns:ext="http//my.company.org/naaccrxml"
And here is an example of a non-standard root attribute using that namespace:
ext:myAttribute="myValue"
The standard also allows non-standard tags to appear in specific locations of the XML data files (those blocks of non-standard XML are called extensions). Those also need to be defined under their own namespace. Here is an example of an extension block:
<ext:MyTag>
<ext:MyOtherTag>value<ext:MyOtherTag>
</ext:MayTag>
This wiki contains a full section providing more details about extensions.