Package ca.uhn.hl7v2.validation.impl
Class XMLSchemaRule
java.lang.Object
ca.uhn.hl7v2.validation.impl.RuleSupport<String>
ca.uhn.hl7v2.validation.impl.AbstractEncodingRule
ca.uhn.hl7v2.validation.impl.XMLSchemaRule
- All Implemented Interfaces:
EncodingRule,Rule<String>,Serializable
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionTest/validate a given xml document against a hl7 v2.xml schema.Returns a text description of the rule.Returns a string indicating the section of the HL7 standard from which this rule is derived (if applicable).voidsetSchemaLocations(Map<String, String> locations) Methods inherited from class ca.uhn.hl7v2.validation.impl.AbstractEncodingRule
testMethods inherited from class ca.uhn.hl7v2.validation.impl.RuleSupport
failed, failed, failed, failed, failedWithValue, getErrorCode, getSeverity, passed, result, result, setDescription, setErrorCode, setSectionReference, setSeverity
-
Constructor Details
-
XMLSchemaRule
public XMLSchemaRule()
-
-
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
-
getDescription
Description copied from interface:RuleReturns 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:
getDescriptionin interfaceRule<String>- Overrides:
getDescriptionin classRuleSupport<String>- Returns:
- rule description
- See Also:
-
getSectionReference
Description copied from interface:RuleReturns 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:
getSectionReferencein interfaceRule<String>- Overrides:
getSectionReferencein classRuleSupport<String>- Returns:
- HL7 specification section reference
- See Also:
-