views:

57

answers:

1

I'm writing a GWT-Hibernate internal web application for our development group.

Previously, I had written tools to parse up XML files which represented customer configuration gathered in the field for analysis. Now, I'm trying to add an UI front-end for the support group. The XML parsing code uses xpath and org.w3c.dom classes to consume the config files, after merging the UI and parsing code into the same project I've run into a dependency issue. Hibernate 3.5.1 depends on dom4j which uses a old version of xml-apis. The xml-apis jar has old versions of the org.w3c.dom classes, so old that one of the methods I'm using in the XML parsing isn't available.

The method org.w3c.dom.Node.getTextContext which is not available in the old xml-apis classes.


Node node = (Node)xpath.evaluate("//probe/configfile[@group=\"daemon.ini\"]/content", data, XPathConstants.NODE);
        if(node != null) {
            String content = node.getTextContent();
                // Do more work...

The maven dependency:tree shows the issue, hibernate, dom4j, xml-apis 1.0.b2.

[INFO] +- org.hibernate:hibernate-core:jar:3.5.1-Final:compile
[INFO] |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  \- xml-apis:xml-apis:jar:1.0.b2:compile

Suggestions on the best way to solve this issue?

  1. Maven dependency configuration? I'm new to maven, so be explicit.
  2. Parse the XML using a different API?

Thanks in advance.

A: 

I don't know what version(s) would be ok for you but can control the versions of transitive dependencies by declaring them in the <dependencyManagement> element:

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis</artifactId>
        <version>1.3.04</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

Here is what you'd get:

[INFO] +- org.hibernate:hibernate-entitymanager:jar:3.5.4-Final:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:3.5.4-Final:compile
[INFO] |  |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  |  +- commons-collections:commons-collections:jar:3.2:compile
[INFO] |  |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  |  \- xml-apis:xml-apis:jar:1.3.04:compile (version managed from 1.0.b2)

But as I wrote, I don't know what version would suit your needs and if they are backward compatible.

Pascal Thivent
Thank you, that worked perfectly. I need to read more of the maven docs.
KaizenSoze