xml-soap-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dswans...@mmm.com
Subject Re: Validator for xml-schema & xml documents...
Date Fri, 01 Jun 2001 13:26:38 GMT

Kuntal,
     I recently went through the validation scenerio and I did not find any
good examples of how to implement schema validation (ie good code examples)
but the apache site did have an example of a namespace/nonamespace
schema...here is a snippet of code that I used to get the validation of XML
documents to work...(using xerces1.4)...


DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
     factory.setValidating(true);
     factory.setNamespaceAware(true);
     MyErrorHandler err = new MyErrorHandler(); //inherited from
org.xml.sax.ErrorHandler

     DocumentBuilder builder = factory.newDocumentBuilder();
     builder.setErrorHandler(err);

     Document mydoc = builder.parse(new InputSource
("file:///D:/MES_WebSite/development/xmldoc/person-schema3.xml"));

If any errors pop they are handed to your error handler...the problem that
I see is that the XML docs must have a reference to the exact location/name
of the schema document....IMHO this presents a problem if you are exposing
some methods via SOAP that accept an XML document as an
argument...obviously you would want to validate that the document coming in
is valid for the requested soap service...all of the clients calling your
service would have to construct their documents with intimate knowledge of
the location of your schemas....Also I haven't found an example of how to
cache these documents...

Anyways, end of personal rant and if you think of a solution to these
shortcomings please let me know.

thanks
Doug


Mime
View raw message