You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Bart Molenkamp <b....@bizzdesign.nl> on 2004/10/08 12:29:11 UTC
Merging CForm's DOMHelper with DOMUtil?
Hi all,
I need to parse XML files to documents. I found out that CForm's
DomHelper class could be very useful for that, mostly because it records
line and character positions of nodes. Isn't this useful for other
Cocoon parts as well? Thus making this class more globally available in
Cocoon? Or maybe merge it with DOMUtil?
Bart.
Re: Merging CForm's DOMHelper with DOMUtil?
Posted by Vadim Gritsenko <va...@reverycodes.com>.
Bart Molenkamp wrote:
>
> I need to parse XML files to documents.
Why don't you use SourceResolver and SourceUtil?
> I found out that CForm's
> DomHelper class could be very useful for that, mostly because it records
> line and character positions of nodes. Isn't this useful for other
> Cocoon parts as well? Thus making this class more globally available in
> Cocoon? Or maybe merge it with DOMUtil?
Unfortunately, this works only with Xerces, and it works only with Xerces DOM
documents, and only when those documents were created by the method in this helper.
Moreover, this helper will fail with ClassCastException if "foreign" DOM is
passed instead of degrading gracefully. Even worse, it will fail with
NoClassDefFoundError if Xerces isn't in the classpath.
In short, there is some refactoring required in order to make it possible to
bring this functionality into the DOMUtil. But, some of the methods could easily
be moved into the DOMUtil.
This also shows that CForms currently do some unefficient double parsing if
XMLizable source is passed to it.
This also makes me think; LocationTrackingDOMParser could be an alternative
implementation of cocoon.xconf's <xml-parser/>, making location information
available globally in Cocoon.
Vadim