commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Engstrom <>
Subject [configuration] XPathExpressionEngine inconsistency in setProperty/addProperty
Date Wed, 14 May 2008 03:41:46 GMT
Hello, thanks for the great product.  I have been using
commons-configuration for some time but am new to the
XPathExpressionEngine and am having trouble figuring out how to use it

I am trying to use the XPathExpressionEngine to populate a new
XMLConfiguration using commons-configuration-1.5.  It seems that
setProperty will create a new attribute for the root but not for child

Can you please explain why the following works:

XMLConfiguration config = new XMLConfiguration();
config.setExpressionEngine(new XPathExpressionEngine());
config.setProperty("/ @version", "1.0");

but if I add a child node to the root and then try to add a new
attribute to the child using setProperty it fails:

config.setProperty("/ child", "");
config.setProperty("/child @name", "child0");  //Fails with
"org.apache.commons.jxpath.JXPathException: Invalid XPath: '/child
@name'. Syntax error after: '/c'"

If I change the last call to setProperty to addProperty the new
attribute is created and after that I can call setProperty with out
getting an exception.

Is this a bug, or do I not understand how this should work?

I also expected to be able to create the child node and the attribute
with one call like:

config.setProperty("/ child/@name", "child0"); //Fails with
java.lang.IllegalArgumentException: Invalid node path: "child/@name"
contains an attribute delimiter at an unallowed position.

Thanks for your time,


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message