Andy,

As you already have found out, there is a problem in the code that
handles default namespace mapping - xupdate library maps default
namespace URL to null, and Xindice expects empty string instead. You
can change line 63 in the class org.apache.xindice.xml.NamespaceMap to

if (pfx == null) {...}

That should take care of the exception. I will patch the code in
Xindice trunk sometime today.

The other problem where XUpdate query fails to update a document
happens because of a mistake in the query. It's selection criteria
should be changed to this:

<?xml version="1.0" encoding="UTF-8"?>
<xu:modifications xmlns:xu="http://www.xmldb.org/xupdate"; version="1.0">
   <xu:insert-after select="/foo:root/bar:top">
       <interface xmlns:b="lett.com/example"
xmlns:urn="urn:ietf:params:xml:ns:netconf:base:1.0">
         <name>Ethernet0/0</name>
         <mtu>1500</mtu>
       </interface>
   </xu:insert-after>
</xu:modifications>

The XPath expression (/foo:root/bar:top) changed to match document
structure and namespaces. In the sample document both root and top
nodes are in the default namespaces, which makes it necessary to
explicitly provide namespace prefixes in XPath expression and use
prefix resolver to resolve these prefixes.

This way, code for modifying a resource can be:

XUpdateQueryServiceImpl service = (XUpdateQueryServiceImpl)
collection.getService("XUpdateQueryService", "1.0");
service.setNamespace("foo", "http://lett.com/ns/netconf/server/1.0";);
service.setNamespace("bar", "lett.com/example");

service.updateResource(resourceName, xupdateQuery);

Can you try this and see if it works for you?

Natalia


On Sat, Dec 27, 2008 at 1:47 PM, Todd Byrne <toddby...@gmail.com> wrote:
> Hi Andy,
>
> Last time I worked on the xupdate source code I used this download from
> sourceforge and it matched up in the debugger.
>
> http://sourceforge.net/project/showfiles.php?group_id=75532&package_id=160698&release_id=348903
>
> Start with the 0.3 version.
>
> I have used xupdate with Xindice extensively but I didn't have any namespace
> so I don't know off the top of my head how to fix this particular NPE. If
> you can spend some more time tracking this into the xupdate source code.
> Please keep us abreast of any results you find.
>
> Todd Byrne
>
> On Sat, Dec 27, 2008 at 11:19 AM, Andy Putnins <putn...@lett.com> wrote:
>>
>> I guess this boils down to the question of how namespaces are handled by
>> Xupdate.
>>
>> I tried this same xupdate modification on an eXist database. It doesn't
>> throw a Null Pointer exception, but instead it ignores the entire
>> modification. The only way I can get it to apply the modification is by
>> removing both of the default namespace attributes
>> (xmlns="http://lett.com/ns/netconf/server/1.0"; on the <root> element and
>> xmlns="lett.com/example" on the <top> element).
>>
>> I would really appreciate it if someone could explain what is going on
>> here.
>>
>>   - Andy
>>

Reply via email to