Menu

#251 Cannot disable XMLParser validation in HAPI 2 v2.3

2.3
open
nobody
None
5
2018-10-17
2018-10-15
Hao Trinh
No

Hi,
Disable validation (eg: context.getParserConfiguration().setValidating(false)) only works for PipeParser, but it does not work for the XMLParser in Hapi 2 v2.3.

Note: the codes below work with Hapi 2 v2.2

String inValidMessage = "MSH|^~\\&|MedSeries|CAISI_1-2|PLS|3910|200903230934||ADT^A31^ADT_A05|75535037-1237815294895|P^T|2.4\r"
+ "EVN|A31|THIS-IS-NOT-DATE-VALUE\r"
+ "PID|1||29^^CAISI_1-2^PI~\"\"||Test300^Leticia^^^^^L||19770202|M||||||||||||||||||||||";

HapiContext context = new DefaultHapiContext();
context.getParserConfiguration().setValidating(false); // disable validation
Message hapiMsg = null;
String xmlDoc = null;
PipeParser parser = context.getPipeParser();
hapiMsg = parser.parse(inValidMessage); // successfull parsed

xmlDoc = xmlParser.encode(hapiMsg,"XML");
XMLParser xmlParser = context.getXMLParser();

Message xmlMessage = xmlParser.parse(xmlDoc);// an exception is thrown here
//Validation failed: Primitive value 'THIS-IS-NOT-DATE-VALUE' requires to be empty or a HL7 datetime string

Discussion

  • Hao Trinh

    Hao Trinh - 2018-10-17

    Thanks Christian for the fix!

     

Log in to post a comment.