DOM 3 with Xerces-J

D

Dale Gerdemann

I've been trying to use DOM level 3 with xerces-2_6_2. There's a
sample called samples/DOM3.java, but I've had trouble with
compilation. I've downloaded Xerces-J-bin.2.6.2 and
beta2-dom3-Xerces-J-bin.2.6 and added the following paths to my CLASSPATH:

..../xerces-2_6_2/xercesImpl.jar:
..../xerces-2_6_2/dom3-xercesImpl.jar:
..../xerces-2_6_2/dom3-xml-apis.jar:
..../xerces-2_6_2/xmlParserAPIs.jar:
..../xerces-2_6_2/xercesSamples.jar:
..../xerces-2_6_2/xml-apis.jar:
..../xerces-2_6_2/resolver.jar

When I compile dom/DOM3.java, I get 4 errors:

dom/DOM3.java:113: incompatible types
found : org.apache.xerces.dom3.DOMConfiguration
required: org.w3c.dom.DOMConfiguration
DOMConfiguration config = builder.getDomConfig();
^
dom/DOM3.java:144: cannot resolve symbol
symbol : method getDomConfig ()
location: interface org.w3c.dom.Document
config = doc.getDomConfig();
^
dom/DOM3.java:158: cannot resolve symbol
symbol : method normalizeDocument ()
location: interface org.w3c.dom.Document
doc.normalizeDocument();
^
dom/DOM3.java:165: incompatible types
found : org.apache.xerces.dom3.DOMConfiguration
required: org.w3c.dom.DOMConfiguration
config = domWriter.getDomConfig();


The first error occurs on a line that looks like:

DOMConfiguration config = builder.getDomConfig();

The error can be "fixed" in either of two ways:

org.apache.xerces.dom3.DOMConfiguration config =
builder.getDomConfig();

DOMConfiguration config =
(org.w3c.dom.DOMConfiguration)builder.getDomConfig();

The fourth problem can also be "fixed" like this. The second and third
problems are however unclear to me. In case it makes any differnce,
I'm running java 1.4.1 under Solaris.



I'm generally uncertain whether I should be using DOM 3 in the first
place. The problem I'm working with involves extending an XML document
by picking out elements from several other XML files. If I'm extending
document A by looking in B, C and D,

I thought I would load A into a DOM tree and then use XPath to pick
out the various elenents of B, C and D that need to be added to A. To
do this, I need an environment where XPath and DOM can be used
together in a common framework. I need, e.g., to be able to evaluate
an XPath expression to get a NodeList that DOM can understand.

My first assumption was that I would use JAXP, and maybe this is the
right way to go. But I thought I might try DOM 3 Load and Save since:

1. It's the latest greatest technology.
2. It's supposed to be more general than JAXP.
3. It's cross platform (useful if I need to teach these things later
in a Perl course).

Maybe my assumptions are wrong, but this is what I understand from
what I have read. Any suggestions would be greatly appreciated.



Dale Gerdemann
Universitaet Tuebingen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top