xml-xindice-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Greif" <jgr...@alumni.princeton.edu>
Subject Bug in xupdate (in dbxml-1.0b4) involving namespaces
Date Wed, 26 Jun 2002 15:55:23 GMT
Note that I'm using dbxml-1.0b4, so there is a chance this has already been fixed.  I'll attempt
to test it in the released xindice if I get a chance.

It seems that the presence of namespaces other than the xupdate namespace in an xupdate query
can cause it to fail.  The failure is not evident in the result of XUpdateQueryService.updateResource,
but rather only by looking at the resulting document and seeing that nothing happened.

Here are two almost identical xupdate queries, differentiated only by the presence of an additional
namespace declaration (xmlns:src=....) and usage (src:key=....) in Query1.

Query1:

<xupdate:modifications version='1.0'
xmlns:xupdate='http://www.xmldb.org/xupdate'
xmlns:src="http://xml.apache.org/xindice/NodeSource">
<xupdate:append
select='/WbStorageFormat/Body/UnmodifiedDirectory/Bindings'>
<xupdate:element name="Binding">
<xupdate:attribute name="name">bozo</xupdate:attribute>
<xupdate:attribute name="timestamp">1025053009605</xupdate:attribute>
<xupdate:attribute name="controlling">true</xupdate:attribute>
<xupdate:attribute name="flags">0</xupdate:attribute>
<ObjectId collection="ViewWithVMCs" host="JMG" src:key="/rootview/bozo~!~">
<Uname>/rootview/bozo</Uname>
<VmcName></VmcName>
</ObjectId>
</xupdate:element>
</xupdate:append>
</xupdate:modifications>

Query2:

<xupdate:modifications version='1.0'
xmlns:xupdate='http://www.xmldb.org/xupdate'
>
<xupdate:append
select='/WbStorageFormat/Body/UnmodifiedDirectory/Bindings'>
<xupdate:element name="Binding">
<xupdate:attribute name="name">bozo</xupdate:attribute>
<xupdate:attribute name="timestamp">1025053009605</xupdate:attribute>
<xupdate:attribute name="controlling">true</xupdate:attribute>
<xupdate:attribute name="flags">0</xupdate:attribute>
<ObjectId collection="ViewWithVMCs" host="JMG">
<Uname>/rootview/bozo</Uname>
<VmcName></VmcName>
</ObjectId>
</xupdate:element>
</xupdate:append>
</xupdate:modifications>

I modified the xupdate sample to read the xupdate query from a file and apply it to a particular
resource, not the entire collection, (see below).  The first of the queries appears to succeed
(the call to XUpdateQueryService.updateResource on the client completes), but actually an
exception has been caught internally on the server and no actual change to the resource occurs,
but Query2, tried in identical circumstances, works just fine.  The exception for Query1 is:

java.lang.NullPointerException
        at org.infozone.lexus.commands.InsertAttribute.execute(InsertAttribute.java:49)
        at org.infozone.lexus.commands.InsertCommand.executeInstruction(InsertCommand.java:128)
        at org.dbxml.core.xupdate.XUpdateImpl.execute(XUpdateImpl.java:105)
        at org.dbxml.core.xupdate.XUpdateQueryResolver$XUpdateQuery.execute(XUpdateQueryResolver.java:155)
        at org.dbxml.core.xupdate.XUpdateQueryResolver.query(XUpdateQueryResolver.java:99)
        at org.dbxml.core.query.QueryEngine.query(QueryEngine.java:139)
        at org.dbxml.core.Collection.queryDocument(Collection.java:838)
        at org.dbxml.core.corba.CollectionServant.queryDocument(CollectionServant.java:446)
        at org.dbxml.core.corba.db.CollectionPOA._invoke(CollectionPOA.java:355)
        at org.openorb.adapter.poa.POA.dispatch(POA.java:975)
        at org.openorb.net.AbstractServerRequest.dispatch(AbstractServerRequest.java:750)
        at org.openorb.net.ServerManagerImpl.serve_request(ServerManagerImpl.java:1467)
        at org.openorb.net.ServerManagerImpl.thread_pool_main(ServerManagerImpl.java:1410)
        at org.openorb.net.ServerManagerImpl.access$200(ServerManagerImpl.java:77)
        at org.openorb.net.ServerManagerImpl$PoolThread.run(ServerManagerImpl.java:1557)

------------------------------------------ sample code tryxupdate.java --------------------------------
/*
 * dbXML Core - Example Code
 *
 * Copyright (c) 1999-2001 The dbXML Group
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy 
 * of this software and associated documentation files (the "Software"), to 
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
 * sell copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 *
 *    The above copyright notice and this permission notice shall be included 
 *       in all copies of substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
 * IN THE SOFTWARE.
 *
 * $Id: XUpdate.java,v 1.2 2001/09/09 18:07:41 kstaken Exp $
 */

/* Modified to read the query from a file specified in
 * command line args and a collection specified in command line args.
 * Jeff Greif, Webalo Inc.
 */

import java.io.*;

import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;

/**
 * Simple XML:DB API example to update the database.
 */
public class tryxupdate {
   public static void main(String[] args) throws Exception {
      Collection col = null;
      try {
         String driver = "org.dbxml.client.xmldb.DatabaseImpl";
         Class c = Class.forName(driver);
         
         Database database = (Database) c.newInstance();
         DatabaseManager.registerDatabase(database);
         col =
            DatabaseManager.getCollection(args[0]);

  BufferedReader b = new BufferedReader(new FileReader(args[2]));
  StringBuffer sb = new StringBuffer();
  String xupdate = null;
  String id = args[1];
  try {
      String line = null;
      do  {
   line = b.readLine();
   if (line != null ) {
       sb.append(line).append("\n");
   }
      } while (line != null );
      
  } catch (IOException ie) {
      
  }
  xupdate = sb.toString();
  System.out.println(xupdate);
  
         XUpdateQueryService service =
            (XUpdateQueryService) col.getService("XUpdateQueryService", "1.0");
  service.updateResource(id, xupdate);
  System.out.println("xupdate succeeded.");
      }
      catch (XMLDBException e) {
         System.err.println("XML:DB Exception occured " + e.errorCode + " " + 
            e.getMessage());
  e.printStackTrace();
      }
      finally {
         if (col != null) {
            col.close();
         }
      }
   }
}


Mime
View raw message