I have to validate my xml file with a given XSD file and for that I am using SaxReader with attribute hParser:NONAMESPACE-SCHEMA-LOCATION = "c:\abc.xsd" and hParser:VALIDATION-ENABLED = TRUE.
My xsd file is not correct, even if it is complete garbage it wont give me a error message.
I added error callback and also SAX-PARSE() in a persistent procedure but still i get no errors.
Please log a bug for this. I was able to get to an error using x-document:load(), but not with sax-parse(). We'd need to debug the situation.
hDoc:load() validates only XML file structure, not against external XSD file. I also tried below options but still no success.
hDoc:SCHEMA-PATH = "validate.xsd".
hDoc:NONAMESPACE-SCHEMA-LOCATION = "validate.xsd".
I tried these options for Sax reader as well but getting same result.
Is there any other way to validate XML file against the external XSD file ?
I tried that too as below but still not validating.
CREATE SAX-READER hParser.
RUN Service\ParseXML.p PERSISTENT SET hCallbacks.
hParser:HANDLER = hCallbacks.
hParser:VALIDATION-ENABLED = TRUE . /* no dtd validation, only XSD */
hParser:NONAMESPACE-SCHEMA-LOCATION = "validate.xsd".
hParser:SCHEMA-PATH = "validate.xsd".
REPEAT WHILE hParser:PARSE-STATUS = SAX-RUNNING:
CASE hParser:PARSE-STATUS :
WHEN SAX-COMPLETE THEN DO :
MESSAGE "sax parser complete" VIEW-AS ALERT-BOX.
WHEN SAX-PARSER-ERROR THEN DO :
MESSAGE "sax parser error" VIEW-AS ALERT-BOX.
OTHERWISE DO :
MESSAGE "Unknown status" VIEW-AS ALERT-BOX.
IF ERROR-STATUS:ERROR THEN
IF ERROR-STATUS:NUM-MESSAGES > 0 THEN
MESSAGE ERROR-STATUS:GET-MESSAGE(1) VIEW-AS ALERT-BOX.
MESSAGE RETURN-VALUE VIEW-AS ALERT-BOX.
MESSAGE "Document parsed successfully" VIEW-AS ALERT-BOX.
DELETE OBJECT hParser.
DELETE PROCEDURE hCallbacks.
Yes, I tried that too but still I am not able to catch the error. Actually I am following below sample example provided by progress.
With ERROR-STATUS:ERROR EQ FALSE it is showing 0 num-messages.
hDoc:Load() is supposed to validate the XML document against any .xsd specified with SCHEMA-LOCATION, NONAMSPACE-SCHEMA-LOCATION. As I said previously, please log a bug. Thanks.