System.setProperty(DOMImplementationRegistry.PROPERTY,
"org.apache.xerces.dom.DOMXSImplementationSourceImpl");
DOMImplementationRegistry registry = DOMImplementationRegistry
.newInstance();
DOMImplementationLS impl = (DOMImplementationLS) registry
.getDOMImplementation("psvi");
LSParser parser = impl
.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
But it did gave me success. I was not able to set the deferred dom expansion property to false. The LSParser is not an instance of DOMParser, but is a DOMParserImpl.
At last I just swithed to the method by instantiating a a DOMParser directy:
XMLParserConfiguration config = new XIncludeAwareParserConfiguration();
config.setProperty(
"http://apache.org/xml/properties/internal/grammar-pool",
grammarPool);
parser = new DOMParserExt(config);
parser.setFeature(
"http://apache.org/xml/features/dom/defer-node-expansion",
false); // otherwise parser.getCurrentNode() == null
I added an errorHandler and everything worked fine.
I really wonder if anyone have made this working by JAXP of through the LSParser.
I all started this because Xerces can not revalidate a dom XMLdocument with an attached DTD. Revalidation with schemas is no problem, but revalidation with DTD just gives "random" errors. There is no other way than serialize the document and feed it again to the parser. I did not found a method to feed a Sax or DomParser with just the dom document.
I was hoping that the current-element-node feauture would gave me the same precision of error location as the "revalidation" feature gives. Again I was disappointed. When error are encountered in text values (for instance if they are not a valid value of an enumeration) the current-element-node is "null" again. And errors in attributes, are pointing to the ownerElement.
If I am wrong in my conclusions please let me know.
Regards
Dick Deneer
Dick Deneer heeft op dinsdag, 20 dec 2005 om 08:26 (Europe/Amsterdam) het volgende geschreven:
I am trying to get the current elementNode ( by means of the property "http://apache.org/xml/properties/dom/current-element-node" ) when the domparser reports an error, but I am getting a null node as result.
Using xerces 2.71 wiyh JAXP interface.
Can I use this property for this situation?
