Dick Deneer <[EMAIL PROTECTED]> wrote on 12/21/2005 
12:17:12 PM:

> Because the minimum response I did  some more research to get this 
> working. I first tried to switch to the standard method to setup of a 
> dom parser:
>   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.

In an LSParser context the default value of the defer node expansion 
feature is *false*. It has to have this value in order for the 
implementation to work correctly since an LSParser must be capable of 
passing new nodes to an LSParserFilter before inserting them into the 
tree. This DOM Level 3 feature just doesn't work with a deferred DOM, so 
though I'm not sure why you weren't able to set the feature you probably 
wouldn't want to change its value anyway.
 
> 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.

Right. You can only retrieve the current element node if the deferred node 
expansion feature is set to false.

> I really wonder if anyone have made this working by JAXP of through the 
> LSParser.

Only Xerces' DOMParser returns non-null values when you query the 
current-element-node property. I know that isn't clear from the features 
and properties documentation. Those pages were originally created when 
XMLReader and DocumentBuilder were the only configurable components 
distributed with JAXP. Now there are many more: LSParser, SchemaFactory, 
etc... The Xerces 2.8.0 docs will specify which features and properties 
apply to each component.

Anyhow, there's really no need for the LSParser to support the 
current-element-node property. When there's an error, the DOMError 
reported to your error handler should contain the related node in the 
DOMLocator.

> 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.

That was the case about a month ago. I've fixed [1][2] the most serious 
issues so that doesn't happen anymore. DTD validation in 
normalizeDocument() actually works now. If you're anxious to start using 
this feature, try out one of the nightly builds [3].

> 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?
> >
> >

[1] 
http://svn.apache.org/viewcvs.cgi/xerces/java/trunk/src/org/apache/xerces/dom/CoreDOMImplementationImpl.java?rev=354991&view=log
[2] 
http://svn.apache.org/viewcvs.cgi/xerces/java/trunk/src/org/apache/xerces/dom/DOMNormalizer.java?rev=355001&view=log
[3] http://vmgump.apache.org/gump/public-jars/xml-xerces2/jars/

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to