Hi,
Im probably doing something silly, but somehow i cant seem to validate an xsd with a saxreader.
As far as im aware in progress 9 there was only support for DTD's.
For that purpose there is a SCHEMA-PATH attribute and a VALIDATION-ENABLED attribute. But in openedge there are 2 new attributes that support validation against XML schema (xsd).
But whatever i put in my xsd file, even if it is complete garbage it wont give me an errorcode or a message or anything. So i must be doing something wrong here i think. Below i entered some testcode.
So this is in short a testsnippet :
DEF VAR hParser as HANDLE.
DEF VAR hHandler AS HANDLE.
/* create the SAX-READER object */
CREATE SAX-READER hParser.
/* run the persistent procedure that contains the callbacks */
RUN "c:\zooi\sax\i-sax2h.p" PERSISTENT SET hHandler.
/* give the SAX-READER the handle to the persistent procedure */
hParser:HANDLER = hHandler.
hParser:SET-INPUT-SOURCE("FILE", "c:\zooi\sax\i-sax2.xml"). /* test xml file with no namespaces */
hParser:VALIDATION-ENABLED = FALSE . /* no dtd validation, only XSD */
hParser:SUPPRESS-NAMESPACE-PROCESSING = TRUE . /* there r no namespaces in the test xml anyway */
/*
hParser:ADD-SCHEMA-LOCATION( "http://localhost", "sax2.xsd" ) .
*/
hParser:NONAMESPACE-SCHEMA-LOCATION = "c:\zooi\sax\sax2.xsd" . /* this is the one it should use i think */
hParser:SAX-PARSE( ) NO-ERROR.
CASE hParser:PARSE-STATUS :
WHEN SAX-COMPLETE THEN DO :
MESSAGE "sax parser complete" VIEW-AS ALERT-BOX.
END.
WHEN SAX-PARSER-ERROR THEN DO :
MESSAGE "sax parser error" VIEW-AS ALERT-BOX.
END.
OTHERWISE DO :
MESSAGE "Unknown status" VIEW-AS ALERT-BOX.
END.
END CASE.
IF ERROR-STATUS:ERROR THEN
DO:
IF ERROR-STATUS:NUM-MESSAGES > 0 THEN
/* unable to begin the parse */
MESSAGE ERROR-STATUS:GET-MESSAGE(1) VIEW-AS ALERT-BOX.
ELSE
/* error detected in a callback */
MESSAGE RETURN-VALUE VIEW-AS ALERT-BOX.
END.
ELSE
MESSAGE "Document parsed successfully" VIEW-AS ALERT-BOX.
DELETE OBJECT hParser.
DELETE PROCEDURE hHandler.
Hmm i found a similar problem in knowledgebase P63186, even if this one is for DTD's and not XSD.
The're suggesting to add an error callback, i tried that but still i get no errors on any xsd...
Hmm i found a similar problem in knowledgebase
P63186, even if this one is for DTD's and not XSD.
The're suggesting to add an error callback, i tried
that but still i get no errors on any xsd...
Maybe the error callback only works when the procedure executing the SAX-PARSE() is a persistent procedure. Did you try that?