commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitri Plotnikov <dmi...@apache.org>
Subject Re: [JXPATH] Error when create DOM Element without prefix of namespace using createPathAndSetValue()
Date Fri, 11 Feb 2005 22:55:45 GMT
ijorge,
 
Thank you very much for the bug report.  I will apply the patch you provided.
 
Regards,
 
- Dmitri

ijorge <ijorge@ignos.com> wrote:
I'm using JXPATH to generate a DOM Element. I have this structure:


PUBLIC "-//Example//DTD Example/EN"
"http://www.example.com/example">

name="root"
xmlns="http://www.example.com/example"
xmlns:exa="http://www.example.com/example">






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

But, I received this error:
Factory could not create a child node for path: 
$root/example1[@name='aa']/example2[1]

I tried this other sentence:
context.createPathAndSetValue("$root/example1[@name='aa']/exa:example2", 
"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/DOMNodePointer.java
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:
397c397,401
< 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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message