Schema Referencing in PDS4 Labels

From The SBN Wiki
Revision as of 13:28, 15 April 2015 by Raugh (talk | contribs) (Created page with "There are several ways to tie schema documents to the XML files they define in order to validate them and take advantage of schema-aware editors; but in general these methods ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

There are several ways to tie schema documents to the XML files they define in order to validate them and take advantage of schema-aware editors; but in general these methods are not compatible with each other. In other words, XML editors need to pick the method they want to use, and then use it consistently. Trying to change methods generally involves changing software settings and/or editing the schema references in the XML files.

The PDS4 schema library is relatively complex and interlinked. That is, the PDS4 dictionary schemas - the ones that define the core PDS and discipline name spaces as well as the mission dictionaries - cross-reference each other. In order for any particular software environment, then, to be able to resolve all schema references reliably, it will be rather important that the same technique be used in all dictionary schemas and all label files, regardless of source.

This page describes how to set up your PDS4 labels to be consistent with the PDS schema library. This method is very strongly recommended to PDS4 data preparers. In fact, your node consultant may insist on it in order to have consistent and reliable validation of your deliveries.

Preliminaries

PDS-controlled namespaces will almost always be defined by a pair of related schema files: an XML Schema (.xsd) file to define the class structures and general data types; and a Schematron (.sch) file to define enumerated value lists and conditional structure relationships (e.g., you must use PDS attribute A or PDS attribute B, but not both). You will need to tie your labels to both of these files. The Schematron file will be referenced in the XML prolog; the XSD file will be referenced in the document root tag (<Product_Observational>, for example).


Note: Schema File vs. Namespace

URIs (Uniform Resource Identifiers) are used to identify both namespaces and the files that define those namespaces. While it is easy, given the naming conventions, to conflate these two things, they are and remain very different concepts to your software. The namespace URI is a logical identifier - it refers to the concept of the dictionary, irrespective of minor version changes. That is, version 1.3 of the PDS core namespace, for example, has exactly the same URI as version 1.5 of the same namespace. (Version 2.0, though, would be a different namespace.)

The schema URIs, however, must resolve to physical files. It is the schema URIs that control the version of the namespace actually applied to the label for editing assistance and for validation.

The practical upshot for PDS4 labels is that when you are referencing a schema file, your URI will contain a file name. When you are referencing a namespace, it will not.

Schematron References

Schematron references are placed in the prolog of the document. (The prolog is everything before the document root tag.) They follow the XML declaration and are included in <?xml-model>][poiuytrewq