The inherent flexibility of NIEM proves to be an incredibly beneficial when used correctly, however this benefit can also be one of its largest banes. Sometimes this flexibility can lead to confusion when implementers attempt to deploy a NIEM exchange which is “valid” according to the XSD, yet not what the recipient is expecting.
One such example is NIEM’s usage of substitution groups where a variety of data elements are legal according to the schema, but rarely are all of these legal options accounted for by the recipient’s adapter. Take NIEM’s DateType as an example. It employs the explicit substitution group (abstract data element) of nc:DateRepresentation which can be one of several different data types. This representation can be replaced with a date (2009-01-01), a date/time (2009-01-01T12:00:00), a month and a year (01-2009), etc.
Lets assume for a minute that a document has two different dates: a document filed date, and a person’s birth date. The publisher’s intention is that filed date be a “timestamp” which includes both a date and a time, while the birth date is simply a date including a month, day and year. A valid sample XML payload would look something like the following:
<?xml version="1.0" encoding="UTF-8"?> <ns:SomeDocument> <nc:DocumentFiledDate> <nc:DateTime>2009-01-01T01:00:00</nc:DateTime> </nc:DocumentFiledDate> <nc:Person> <nc:PersonBirthDate> <nc:Date>1970-01-01</nc:Date> </nc:PersonBirthDate> </nc:Person> </ns:SomeDocument>
The Schematron code to enforce the publisher’s intentions could appear as the following:
<pattern id="eDocumentDateTime"> <title>Verify the document filed date includes a date/Time</title> <rule context="ns:SomeDocument/nc:DocumentFiledDate"> <assert test="nc:DateTime"> A date and a time must be provided as the document filed date. </assert> </rule> </pattern> <pattern id="ePersonBirthDate"> <title>Ensure the person's birth date is an nc:Date.</title> <rule context="ns:SomeDocument/nc:Person/nc:PersonBirthDate"> <assert test="nc:Date"> A person's birth date must be a full date. </assert> </rule> </pattern>
This is a great example of how Schematron can help clarify a publisher’s intent as NEIM-conformant services are developed and deployed.
No comments:
Post a Comment