Reading XSD from Database

lundi 22 septembre 2014

Hi,



I need to validate the HL7 message, seems like best way to do is to validate it with a XSD file and it appears to be working well if the file is present on the file system. But If keep the xsd in the database and then run the same channe....While reading the XSD from the database it gives an error (enclosed with this post.



Here is the code:

function validateHL7Msg(incomingXml)

{

var validMessage = true;

var HL7xml = new XML(SerializerFactory.getSerializer('HL7V2').toXML (incomingXml));

try

{

//SQLText = "select DEXPropXML from dbo.DEXUserProperties where Property = 'ClaimTrakValidationXml'";

SQLText = "select hl7 from schemaValidation";

ResultSet = dbConn.executeCachedQuery(SQLText);

while (ResultSet.next())

{

var clobdata = ResultSet.getClob(1);

var cloblength = clobdata.length();

var StringXML = clobdata.getSubString(1, cloblength);

var Validations = new XML(StringXML);

}

}

finally

{

dbConn.close();

}



var schemaFile = new Packages.java.io.File(StringXML); // like "C:\\hl7v3\\schema.xsd"

//var schemaFile = new Packages.java.io.File("D://HL7Message.xsd");

logger.info("here");

// create a schema object

var schemaFactory = Packages.javax.xml.validation.SchemaFactory.newIns tance("http://ift.tt/WPkwi5;);

var schema = schemaFactory.newSchema(schemaFile);

logger.info('schema '+schema);

var xsdfile = Packages.java.lang.String(schema);

logger.info('xsdfile '+xsdfile);



// Create a Reader from the incoming XML message

//var reader = new Packages.java.io.StringReader(connectorMessage.get RawData());

var reader = new Packages.java.io.StringReader(HL7xml);



// Acts as an holder for a transformation Source in the form of a stream of XML markup.

var xmlFile = Packages.javax.xml.transform.stream.StreamSource(r eader);



// create a new validator for the schema

var validator = schema.newValidator();




Attached Files





File Type: txt Error Message.txt (31.4 KB)







Reading XSD from Database

0 commentaires:

Enregistrer un commentaire