commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ijorge <>
Subject [JXPATH] Error when create DOM Element without prefix of namespace using createPathAndSetValue()
Date Fri, 11 Feb 2005 08:46:16 GMT
I'm using JXPATH to generate a DOM Element. I have this structure:

<?xml version="1.0" encoding="iso-8859-1"?>
    PUBLIC "-//Example//DTD Example/EN"


	<example1 name="aa">


I used this jxpath sentence:  context.createPathAndSetValue(
"$root/example1[@name="aa"]/example2", "xx"); where "example2" must have 
the default namespace xmlns="".

But, I received this error:
Factory could not create a child node for path: 

I tried this other sentence:
"xx"); and this sentence worked correctly.

I have been investigating the source code of JXPATH and I think that the 
error is in org/apache/commons/jxpath/ri/model/dom/
I have modified this class because, in method createChild(), 
NodeNameTest didn´t have the default namespace when (prefix == null):

Diff between modified class and original class from commons-jxpath-1.2:
<         nodeTest = new NodeNameTest(name);
 >         /*
 >          * When new child does not have a prefix, we search the
 >          * default namespace in the ancestors
 >          */
 >          nodeTest = new NodeNameTest(name, getDefaultNamespaceURI());

This change resolves my problem but I don´t know if this behavior is a bug.

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

View raw message