Difference between revisions of "HHG to Namespaces in PDS4"

From The SBN Wiki
Jump to navigation Jump to search
(Creation)
 
m (categories)
Line 72: Line 72:
 
;<nowiki>xmlns:di="http://pds.nasa.gov/pds4/mission/DeepImpact/v1"</nowiki>
 
;<nowiki>xmlns:di="http://pds.nasa.gov/pds4/mission/DeepImpact/v1"</nowiki>
 
:And this line assigns the prefix "di" to be used to reference attributes from the Deep Impact mission (local) dictionary.  Attributes from this dictionary will look like: ''&lt;di:...&gt;''
 
:And this line assigns the prefix "di" to be used to reference attributes from the Deep Impact mission (local) dictionary.  Attributes from this dictionary will look like: ''&lt;di:...&gt;''
 +
 +
 +
[[Category:HHG]]
 +
[[Category:XML]]

Revision as of 20:17, 3 August 2017

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 effect 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 if problems that must be fixed prior to archiving.

Basic Requirements

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 public release will be:

    http://pds.nasa.gov/pds4/pds/v1

The namespace corresponding to the major discipline dictionaries will 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 public release will be:

    http://pds.nasa.gov/pds4/img/v1

Mission dictionaries will have namespaces of the form:

    http://pds.nasa.gov/pds4/mission/<mission-id>/v1

where mission-id is the reserved namespace abbreviation.

After the initial release, dictionaries that are updated or significantly altered will have multiple versions, e.g.:

    http://pds.nasa.gov/pds4/img/v2

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.


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:di="http://pds.nasa.gov/pds4/mission/DeepImpact/v1">

Here we have five different namespaces referenced:

xmlns="http://pds.nasa.gov/pds4/pds/v1"
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.
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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.
xmlns:sbn="http://pds.nasa.gov/pds4/sbn/v1"
This assigns the "sbn" prefix to the SBN discipline dictionary. Attributes from this dictionary will now look like: <sbn:...>.
xmlns:img="http://pds.nasa.gov/pds4/img/v1"
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:...>.
xmlns:di="http://pds.nasa.gov/pds4/mission/DeepImpact/v1"
And this line assigns the prefix "di" to be used to reference attributes from the Deep Impact mission (local) dictionary. Attributes from this dictionary will look like: <di:...>