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 ''&lt;DD_Rule&gt;'' class defines one Schematron <code>&lt;rule&gt;</code> definition.  The Schematron <code>&lt;pattern&gt;</code> 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.  There is much more flexibility in Schematron itself than there is in these classes, and you should use them very carefully as this is an area of active ''Ingest_LDD''/''LDDTool'' development.  Keep your rules very simple and very explicit, and you should be OK.
  
  
Line 18: Line 18:
 
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.   
 
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.
+
'''''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 using the standard colon (':') separator.
  
 
== <rule_assign> ==
 
== <rule_assign> ==
Line 24: Line 24:
 
''OPTIONAL''
 
''OPTIONAL''
  
This attribute is undefinedAvoid it.
+
This attribute is related to adding a Schematron variable definition capability (a <code>&lt;let&gt;</code> defined inside the <code>&lt;rule&gt;</code>This capability is not yet available.  Do not use this attribute.
  
 
== <DD_Attribute_Reference> ==
 
== <DD_Attribute_Reference> ==
Line 30: Line 30:
 
''REQUIRED''
 
''REQUIRED''
  
Despite being required, this class is not documented and does not appear in any of the currently available examples.  Try ignoring it.
+
This is a test construct that was inadvertently designated "required".  Do not use it.  You will have to ignore validation errors complaining that this class is missing.
  
 
== <DD_Class_Reference> ==
 
== <DD_Class_Reference> ==
Line 36: Line 36:
 
''REQUIRED''
 
''REQUIRED''
  
Despite being required, this class is not documented and does not appear in any of the currently available examples.  Try ignoring it.
+
This is a test construct that was inadvertently designated "required".  Do not use it.  You will have to ignore validation errors complaining that this class is missing.
  
 
== <DD_Rule_Statement> ==
 
== <DD_Rule_Statement> ==
Line 42: Line 42:
 
''REQUIRED''
 
''REQUIRED''
  
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.
+
This class defines the various bits and pieces that go into a single <code>&lt;assert&gt;</code> or<code>&lt;report&gt;</code> element.  If the corresponding <code>&lt;rule&gt;</code> element does not already exist, it will be created.
  
 
=== <rule_type> ===
 
=== <rule_type> ===
Line 48: Line 48:
 
''REQUIRED''
 
''REQUIRED''
  
This value indicates the type of test to be defined.  It must be one of four defined values:
+
This value indicates the type of test to be defined.  There are only two defined values you should ever use:
  
 
:::{|
 
:::{|
Line 54: Line 54:
 
| -
 
| -
 
| Creates an <code>&lt;assert&gt;</code> element within the <code>&lt;rule&gt;</code>.
 
| 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'''
 
| align="right" | '''Report'''
Line 72: Line 64:
 
''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.
+
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.  Referencing any other namespace is currently highly problematic and should be avoided.
 +
 
 +
The test string must, of course, use the appropriate Schematron test syntax.
  
 
=== <rule_message> ===
 
=== <rule_message> ===
Line 84: Line 78:
 
''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''.
+
Use this free-text field to provide a human-readable explanation of what is being tested 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> ===
Line 90: Line 84:
 
''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'' valuesUntil it does, consider this technique undocumented and avoid it.
+
This attribute is deprecatedDo not use it.

Revision as of 19:39, 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. There is much more flexibility in Schematron itself than there is in these classes, and you should use them very carefully as this is an area of active Ingest_LDD/LDDTool development. Keep your rules very simple and very explicit, and you should be OK.


<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 using the standard colon (':') separator.

<rule_assign>

OPTIONAL

This attribute is related to adding a Schematron variable definition capability (a <let> defined inside the <rule>. This capability is not yet available. Do not use this attribute.

<DD_Attribute_Reference>

REQUIRED

This is a test construct that was inadvertently designated "required". Do not use it. You will have to ignore validation errors complaining that this class is missing.

<DD_Class_Reference>

REQUIRED

This is a test construct that was inadvertently designated "required". Do not use it. You will have to ignore validation errors complaining that this class is missing.

<DD_Rule_Statement>

REQUIRED

This class defines the various bits and pieces that go into a single <assert> or<report> element. If the corresponding <rule> element does not already exist, it will be created.

<rule_type>

REQUIRED

This value indicates the type of test to be defined. There are only two defined values you should ever use:

Assert - Creates an <assert> element within the <rule>.
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. Referencing any other namespace is currently highly problematic and should be avoided.

The test string 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 tested 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 is deprecated. Do not use it.