HHG to Namespaces in PDS4
Namespaces are a way to provide context for an XML element definition. Two elements with the same name but different namespaces are considered two completely different entities (or should be) by software processing the XML document.
For example, in the phrases "car title" and "movie title", the word title has two very different meanings. "Car" and "movie" each provide a context that has a significant affect on how you interpret "title" in each case.
What It Is
A namespace is a logical concept built in to XML. The XML Namespace standard includes a definition of the correct syntax for namespace identifiers, and also provides a means of locally (that is, within the XML document) defining abbreviations to make namespaces easier for human eyes to track.
PDS4 uses namespaces to identify local data dictionaries. Each local dictionary will have a formal namespace identifier, the format of which is dictated by the PDS4 standards. Each such namespace will also have a reserved abbreviation, to encourage uniformity in referencing namespaces.
What It Is Not
The ability to create local dictionaries and define local namespaces is not an invitation to blow off the PDS4 core requirements and build your own label from scratch. Local namespaces are intended to augment the core PDS requirements, not circumvent them. Local dictionaries will be included in PDS peer reviews, and any local definitions not passing review will be included in the list of problems that must be fixed prior to archiving.
The XML Namespace standard defines an XML attribute, xmlns, that is used to identify a namespace and assign it an abbreviated prefix for easy reference throughout the document. While this attribute can be used with pretty much any XML element, in PDS4 labels you should only see it in the root element of the label.
Reserved XML namespaces
There are defined namespaces for elements from the various XML standards. These will appear in PDS4 labels along with namespace definitions for the PDS4 core and local dictionaries.
PDS4 namespace identifier format
The namespace for the core PDS4 dictionary for the first major version release is:
The namespaces corresponding to the major discipline dictionaries have a similar form, with the reserved discipline namespace abbreviation substituted for the /pds section. For example, the namespace of the Imaging discipline dictionary first major version will be:
Mission dictionaries will have namespaces of the form:
where mission-id is the reserved namespace abbreviation.
When there is a major version increment, the namespace version will change to reflect that:
Major versions changes are intended to indicate non-backwards-compatible boundaries. For the core PDS4 namespace and the discipline dictionaries maintained by PDS, that will always be true and the namespace changes will be coordinated and simultaneous. Mission dictionaries may choose to follow that convention or not, as they need to.
Namespace Identifiers and Resolvable URLs
Note that these namespace identifiers are formatted as URLs. The standard does not require that these URLs be resolvable, but for the foreseeable future PDS intends to maintain these as live URLs, with copies of the dictionary schema files available for referencing at the URL.
More specifically, the actual URL for the PDS namespace will be on a secure server, so the physical location will begin with "https:" rather than "http:". The namespace identifier does not change - it will always be "http:", but if you are hard-coding URLs for referencing the official schemas that define the namespaces, you may use (or may have to use) "https:" for the protocol.
Example Namespace Reference and Abbreviation
Typing the full namespace ID every time you wanted to reference an element from that namespace would get old real quick. The XML Namespace standard provides a way to define a convenient abbreviation within an XML document. We will do this in our PDS4 labels a lot. Here's what the beginning of a typical Small Bodies Node (SBN) PDS4 label might look like:
<Product_Observational xmlns="http://pds.nasa.gov/pds4/pds/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sbn="http://pds.nasa.gov/pds4/sbn/v1" xmlns:img="http://pds.nasa.gov/pds4/img/v1" xmlns:bopps="http://pds.nasa.gov/pds4/mission/bopps/v1">
Here we have five different namespaces referenced:
- This is the core PDS4 dictionary. Note that unlike the next four lines, the xmlns attribute name does not have an attached abbreviation. This assigns the PDS4 core namespace as the default namespace for this label - unless otherwise indicated, the attributes and classes must be found in the PDS4 core dictionary, version 1.
- This assigns the "xsi" prefix to the XMLSchema-instance namespace. It is in this label so that the schemaLocation attribute, defined in that standard, can be used to provide hints to where the defining schemas for each namespace can be found. Depending on your working environment, this may not be necessary.
- This assigns the "sbn" prefix to the SBN discipline dictionary. Attributes from this dictionary will now look like: <sbn:...>.
- This line does for the Imaging discipline dictionary what the last line did for the SBN dictionary. Attributes from this dictionary will look like: <img:...>.
- And this line assigns the prefix "bopps" to be used to reference attributes from the Balloon Observing Platform for Planetary Science (BOPPS) mission (local) dictionary. Attributes from this dictionary will look like: <bopps:filter_name>