Configuring Schematron validation
The PDS4 core standards are contained in two separate schema documents. The first is the master schema, and XML Schema document that defines structures - classes and attributes. The second is a Schematron file. The Schematron Standard provides a syntax for defining relationships between XML document elements, standard value syntax, and conditions more elaborate than the XML Schema standard allows (like co-dependency between elements).
We've already installed the Schematron plug-in and set the validation preferences in Downloading, installing and configuring ''Eclipse''. There is one additional configuration step that must be performed once for each project.
Right-click on the project name in the Project Explorer panel and you should see an Add/Remove Schematron Validation option:
You only have to click on this once for each project, unless, of course, you want to turn schematron validation off. You will not see this option until you installed the schematrom plugin.
- Unfortunately, there is no easy way to tell if schematron validation is currently on or off. We'll cover how to tell if it's working in our demo files below.
The last step needed is telling eclipse where to find the Schematron file to be applied to each label.
In the XML Label
Open the collection_1.0.xml label and look at the top of the file:
<?xml-model> processing instruction line we glossed over a couple pages back? Let's look at it now:
This instruction is trying to tell eclipse that there is a Schematron file (the .sch suffix is commonly reserved for Schematron files) in the PDS4 v08 namespace that should be used for validation.
Ideally, eclipse would use the XML Catalog file to translate this reference to a physical file location. Unfortunately, the Schematron plugin does not, in fact, use the XML Catalog information at all. So to prevent making more copies of the files than necessary, we're going to reference the copy of the schematron file that is in the Schema/ directory - this way, we only need one copy for anything in the current project.
- Note: This is a significant problem for validating PDS labels with eclipse, since local references should never be left in a file destined for archiving. Until someone updates the plugin, however, we're stuck with it. Just remember to replace the reference before archiving, or the label will fail PDS validation.
- (Commercial editors do a better job with this. The oXygen editor, for example, resolves the href values via the catalog file. If you find this has been fixed by an upgrade to the plugin, let us know.)
So, to get Schematron validation to work in our collection_1.0.xml label, change the second line to this:
(The href path is relative to the project root.)
Here's what the top of our label looks like now:
Save the file, and run validation. You should get no errors. (If you do, look for typos in file names and such.)
One of the things enforced by the schematron file is required values for some system keywords. The
<information_model_version> element is one such system keyword - the value has to correspond to the precise version number of the master schema. Try changing one of the characters in the
0.8.0.0.k value. Then save the label file and run validation. You should now see and error message that tells you specifically that your value is not the same as the required value.