Class XMLSchemaRule

All Implemented Interfaces:
EncodingRule, Rule<String>, Serializable

public class XMLSchemaRule extends AbstractEncodingRule
Validates HL7 version 2 messages encoded according to the HL7 XML Encoding Syntax against XML schemas provided by hl7.org.

The XML schema to validate against is determined as follows:

  • if the XML document contains a schemaLocation that points to a valid file, this file is assumed to contain the schema definition
  • the location configured using setSchemaLocations(Map)

The validation fails, if

  • no valid schema file could be found
  • the default namespace of the XML document is not urn:hl7-org:v2xml
  • the document does not validate against the XML schema file foudn as described above
Author:
Nico Vannieuwenhuyze, Christian Ohr
See Also:
  • Constructor Details

  • Method Details

    • apply

      Test/validate a given xml document against a hl7 v2.xml schema.

      Before the schema is applied, the namespace is verified because otherwise schema validation fails anyway.

      If a schema file is specified in the xml message and the file can be located on the disk this one is used. If no schema has been specified, or the file can't be located, the locations property is used.

      Parameters:
      msg - the xml message (as string) to be validated.
      Returns:
      ValidationException[] an array of validation exceptions, which is zero-sized when no validation errors occured.
    • setSchemaLocations

      public void setSchemaLocations(Map<String,String> locations)
    • getDescription

      Description copied from interface: Rule
      Returns a text description of the rule. This description may be used as a message in exceptions generated if validation against the rule fails, or in a user interface for rule configuration.
      Specified by:
      getDescription in interface Rule<String>
      Overrides:
      getDescription in class RuleSupport<String>
      Returns:
      rule description
      See Also:
    • getSectionReference

      Description copied from interface: Rule
      Returns a string indicating the section of the HL7 standard from which this rule is derived (if applicable). Like the description, this may be used in an exception message or configuration UI.
      Specified by:
      getSectionReference in interface Rule<String>
      Overrides:
      getSectionReference in class RuleSupport<String>
      Returns:
      HL7 specification section reference
      See Also: