commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bas Velthuizen" <...@abcoin.nl>
Subject [jxpath] Problems with jxpath and JDOM
Date Wed, 15 Feb 2006 15:54:05 GMT
Hello,

I've been trying to use jxpath 1.2 with jdom 1.0, and when executing the
following code, I get a strange exception:

  private void testModel()
  {
    JXPathContext context = JXPathContext.newContext(this.doc);
    Pointer pointer = context.getPointer("form/name");

    // the following works
    Element elt = (Element) pointer.getNode();
    elt.addContent("bla");

    // the folloing throws an exception
    pointer.setValue("bla");
  }

The exception I get is:
Exception in thread "main" java.lang.NoSuchMethodError:
org.jdom.Element.addContent(Lorg/jdom/Text;)Lorg/jdom/Element;
	at
org.apache.commons.jxpath.ri.model.jdom.JDOMNodePointer.setValue(JDOMNod
ePointer.java:303)
	at com.aci.test.XMLFormsTest.testModel(XMLFormsTest.java:59)

The document (this.doc) is a jdom document containint the following xml
structure:

<form>
  <name />
</form>

When stepping through the code, I see that the JDOMNodePointer uses the
same java statement to set the value of the element.

I noticed that in 2004, the same problem had been seen, and that it was
an incompatibility
http://mail-archives.apache.org/mod_mbox/jakarta-commons-user/200403.mbo
x/%3c060101c40184$57d69cd0$0500a8c0@plotnix2500%3e

What has been fixed and is there a workaround?
(actually I found this while trying to use XmlForm, so a workaround is
somewhat difficult to make).
Cheers,
Bas Velthuizen

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message