Title: DOM Level 3 validation at parse time

Ok, fixing one usually break another.

Does the Level 3 implementation change the way validation is performed at parse time?

Where my application can validate at parse time, I used the following code, which worked fine with 2.4.1

javax.xml.parsers.DocumentBuilderFactory dbf=
javax.xml.parsers.DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setAttribute("http://xml.org/sax/features/validation",Boolean.TRUE);
dbf.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-dtd",Boolean.FALSE);
dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", iXsdValidator.getSchemas());
javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
db.setErrorHandler(iXsdValidator);
Document doc = db.parse(inputStream);

iXsdValidator.getSchemas() returns a java.io.File[] pointing to all schemas (XSD) involved in the validation.

With 2.6.1, using this same exact code, it seems that validation is attempted against a DTD, which I do not have:

// Messages collected by iXsdValidator
error at (2, 15)! Document is invalid: no grammar found.
error at (2, 15)! Document root element "Configuration", must match DOCTYPE root "null".

Has something changed in the way the features and properties are set? Haven't found anything in the docs (yet)

Any help appreciated,

Franck

-----Original Message-----
From: Schmidlin Franck, Home [mailto:[EMAIL PROTECTED]]
Sent: 18 February 2004 15:27
To: '[EMAIL PROTECTED]'
Subject: RE: Validating an already parsed DOM


Typical.. there is always a FAQ to be pointed at =-(

I've had a look at DOMNormalizer in 2.4.0 and I can't see where I could plug it to do what I want to do.

I am going to download 2.6.1 and attempt to enable the DOM level 3 APIs as it seem the best solution in the long term, and every time I attempt to hook with the internal implementation layer I develop a head ache ;-)

Thanks for your help Elena, I'll let you know how it goes.

Franck
-----Original Message-----
From: Elena Litani [mailto:[EMAIL PROTECTED]]
Sent: 18 February 2004 14:46
To: [EMAIL PROTECTED]
Subject: Re: Validating an already parsed DOM


You can start by looking at Xerces docs [1].

If you can't yet use DOM Level 3 - you can play around with internal DOM Level 3 implementation, in particular DOMNormalizer [2]which is basically traverses the DOM tree and sends XNI events to the XML Schema Validator.

However, please note that the DOMNormalizer is internal implemenation and any such classes (and methods) may change/be removed. So use it at your own risk.


[1] http://xml.apache.org/xerces2-j/faq-dom.html#faq-8
[2] http://cvs.apache.org/viewcvs.cgi/xml-xerces/java/src/org/apache/xerces/dom/DOMNormalizer.java

Thank you,
--
Elena Litani/ IBM Toronto


Wednesday, February 18, 2004 8:08 AM
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
cc:
From: "Schmidlin Franck, Home" <[EMAIL PROTECTED]>
Subject: Validating an already parsed DOM


Hello there.
I am currently trying to validate XML documents against XSD schemas, using xerces 2_4_0.
It all works beautifully when I validate at parse time, thank you.
However, my particular application requires me to validate documents that are already parsed and in a DOM Document.
I could serialize the DOM to a string and parse that string again, but that seems like a waste.
Even if I were to create a InputSource around the DOM, or a DomReader, by the time I hit the parse() method, we are again processing strings.

I would prefer to by-pass the parsing and just walk the DOM tree to generate whatever (SAX? XNI?) events are required to run the validation.

I am really struggling to find out where is the most appropriate place to plug in my code?
Where should I look for the code that calls the validation?
XMLParserConfiguration seemed like a good place to start, but between interfaces and factories, the decoupling makes it hard to follow the code.

Please note that I am not a xerces source expert, and I do not build it myself: I just peruse the code.
Any help would be much appreciated.
Thanks
Franck


Scanned for viruses by MessageLabs. The integrity and security of this message cannot be guaranteed. This email is intended for the named recipient only, and may contain confidential information and proprietary material. Any unauthorised use or disclosure is prohibited.


Scanned for viruses by MessageLabs



Scanned for viruses by MessageLabs. The integrity and security of this message cannot be guaranteed. This email is intended for the named recipient only, and may contain confidential information and proprietary material. Any unauthorised use or disclosure is prohibited.


Scanned for viruses by MessageLabs



Scanned for viruses by MessageLabs. The integrity and security of this message cannot be guaranteed. This email is intended for the named recipient only, and may contain confidential information and proprietary material. Any unauthorised use or disclosure is prohibited.

Reply via email to