Difference between revisions of "Filling Out the DD Rule Class"

From The SBN Wiki
Jump to navigation Jump to search
(Creation - Safety Save)
 
(Creation - Safety Save)
Line 1: Line 1:
 
The ability to define Schematron rules gives you another mechanism for validating labels through defined dependencies and contingencies over and above what the XSD Schema standard provides.  For example, you can define a rule that requires that any label that contains ''ClassA'' also contains ''ClassB'', or that all calibrated products contain a class with instrument calibration parameters.  
 
The ability to define Schematron rules gives you another mechanism for validating labels through defined dependencies and contingencies over and above what the XSD Schema standard provides.  For example, you can define a rule that requires that any label that contains ''ClassA'' also contains ''ClassB'', or that all calibrated products contain a class with instrument calibration parameters.  
 
  
 
Each ''<DD_Rule>'' class defines one Schematron ''rule'' definition.  The Schematron ''pattern'' blocks are generated as needed by ''LDDTool''.
 
Each ''<DD_Rule>'' class defines one Schematron ''rule'' definition.  The Schematron ''pattern'' blocks are generated as needed by ''LDDTool''.
 
  
 
You should have an understanding of how to write '''XPath''' specifications and Schematron statements before diving in here, or the terminology can be rather opaque.
 
You should have an understanding of how to write '''XPath''' specifications and Schematron statements before diving in here, or the terminology can be rather opaque.
Line 11: Line 9:
  
 
''REQUIRED''
 
''REQUIRED''
 +
 +
This value provides a handle for this rule within the dictionary.  It must be unique within the ''Ingest_LDD'' file.
  
 
== <rule_context> ==
 
== <rule_context> ==
  
 
''REQUIRED''
 
''REQUIRED''
 +
 +
The value of this attribute is the ''Xpath'' path defining the context for the rule.  Specifically, it provides the value of the <code>context</code>'XML attribute of the Schematron <code>&lt;rule&gt;</code> element. 
 +
 +
'''''N.B.'':''' references to elements defined in this local dictionary ''must'' be prepended with the namespace abbreviation defined in the ''&lt;namespace_id&gt;'' at the top of the ''Ingest_LDD'' class.
  
 
== <rule_assign> ==
 
== <rule_assign> ==
  
 
''OPTIONAL''
 
''OPTIONAL''
 +
 +
This attribute is undefined.  Avoid it.
  
 
== <DD_Attribute_Reference> ==
 
== <DD_Attribute_Reference> ==
Line 24: Line 30:
 
''REQUIRED''
 
''REQUIRED''
  
=== <namespace_id> ===
+
Despite being required, this class is not documented and does not appear in any of the currently available examples.  Try ignoring it.
  
''REQUIRED''
+
== <DD_Class_Reference> ==
 
 
=== <name> ===
 
  
 
''REQUIRED''
 
''REQUIRED''
  
== <DD_Class_Reference> ==
+
Despite being required, this class is not documented and does not appear in any of the currently available examples.  Try ignoring it.
  
''REQUIRED''
+
== <DD_Rule_Statement> ==
 
 
=== <namespace_id> ===
 
  
 
''REQUIRED''
 
''REQUIRED''
  
=== <name> ===
+
This class triggers the creation of a Schematron <code>&lt;rule&gt;</code> element and defines the various bits and pieces that go into a single <code>&lt;assert&gt;</code> and <code>&lt;report&gt;</code> element inside it.
  
''REQUIRED''
+
=== <rule_type> ===
 
 
== <DD_Rule_Statement> ==
 
  
 
''REQUIRED''
 
''REQUIRED''
  
=== <rule_type> ===
+
This value indicates the type of test to be defined.  It must be one of four defined values:
  
''REQUIRED''
+
:::{|
 +
| align="right" | '''Assert'''
 +
| -
 +
| Creates an <code>&lt;assert&gt;</code> element within the <code>&lt;rule&gt;</code>.
 +
|-
 +
| align="right" | '''Assert If'''
 +
| -
 +
| This value is undefined. Avoid it.
 +
|-
 +
| align="right" | '''Assert Every'''
 +
| -
 +
| This value is undefined.  Avoid it.
 +
|-
 +
| align="right" | '''Report'''
 +
| -
 +
| Creates a <code>&lt;report&gt;</code> element within the <code>&lt;rule&gt;</code>
 +
|}
  
 
=== <rule_test> ===
 
=== <rule_test> ===
  
 
''REQUIRED''
 
''REQUIRED''
 +
 +
This attribute contains the text that will go into the <code>test</code> XML attribute of the <code>&lt;assert&gt;</code> or <code>&lt;report&gt;</code> element being defined.  Make sure that you use the local dictionary namespace abbreviation in all references to elements from this dictionary.  It must, of course, use the appropriate Schematron test syntax.
  
 
=== <rule_message> ===
 
=== <rule_message> ===
  
 
''REQUIRED''
 
''REQUIRED''
 +
 +
This attribute provides the message that will be displayed when the associated <code>assert</code> or <code>report</code> is triggered.
  
 
=== <rule_description> ===
 
=== <rule_description> ===
  
 
''OPTIONAL''
 
''OPTIONAL''
 +
 +
Use this free-text field to provide a human-readable explanation of what is being test and why, if it is not already clear from the ''rule_message'' text. This appears to be entirely internal documentation - the description is ''not'' transferred to the output Schematron file produced by ''LDDTool''.
  
 
=== <rule_value> ===
 
=== <rule_value> ===
  
 
''OPTIONAL''
 
''OPTIONAL''
 +
 +
This attribute appears to provide values that can be used for substitution into strings of the Schematron rule definition being created. The documentations provides no additional information on how you would reference these values in your ''rule_message'' or ''rule_test'' values.  Until it does, consider this technique undocumented and avoid it.

Revision as of 16:02, 27 March 2015

The ability to define Schematron rules gives you another mechanism for validating labels through defined dependencies and contingencies over and above what the XSD Schema standard provides. For example, you can define a rule that requires that any label that contains ClassA also contains ClassB, or that all calibrated products contain a class with instrument calibration parameters.

Each <DD_Rule> class defines one Schematron rule definition. The Schematron pattern blocks are generated as needed by LDDTool.

You should have an understanding of how to write XPath specifications and Schematron statements before diving in here, or the terminology can be rather opaque.


<local_identifier>

REQUIRED

This value provides a handle for this rule within the dictionary. It must be unique within the Ingest_LDD file.

<rule_context>

REQUIRED

The value of this attribute is the Xpath path defining the context for the rule. Specifically, it provides the value of the context'XML attribute of the Schematron <rule> element.

N.B.: references to elements defined in this local dictionary must be prepended with the namespace abbreviation defined in the <namespace_id> at the top of the Ingest_LDD class.

<rule_assign>

OPTIONAL

This attribute is undefined. Avoid it.

<DD_Attribute_Reference>

REQUIRED

Despite being required, this class is not documented and does not appear in any of the currently available examples. Try ignoring it.

<DD_Class_Reference>

REQUIRED

Despite being required, this class is not documented and does not appear in any of the currently available examples. Try ignoring it.

<DD_Rule_Statement>

REQUIRED

This class triggers the creation of a Schematron <rule> element and defines the various bits and pieces that go into a single <assert> and <report> element inside it.

<rule_type>

REQUIRED

This value indicates the type of test to be defined. It must be one of four defined values:

Assert - Creates an <assert> element within the <rule>.
Assert If - This value is undefined. Avoid it.
Assert Every - This value is undefined. Avoid it.
Report - Creates a <report> element within the <rule>

<rule_test>

REQUIRED

This attribute contains the text that will go into the test XML attribute of the <assert> or <report> element being defined. Make sure that you use the local dictionary namespace abbreviation in all references to elements from this dictionary. It must, of course, use the appropriate Schematron test syntax.

<rule_message>

REQUIRED

This attribute provides the message that will be displayed when the associated assert or report is triggered.

<rule_description>

OPTIONAL

Use this free-text field to provide a human-readable explanation of what is being test and why, if it is not already clear from the rule_message text. This appears to be entirely internal documentation - the description is not transferred to the output Schematron file produced by LDDTool.

<rule_value>

OPTIONAL

This attribute appears to provide values that can be used for substitution into strings of the Schematron rule definition being created. The documentations provides no additional information on how you would reference these values in your rule_message or rule_test values. Until it does, consider this technique undocumented and avoid it.