vgritsenko    2003/12/11 17:27:23

  Modified:    java/src/org/apache/xindice/client/xmldb/embed
                        CollectionImpl.java
  Log:
  Fix getParentCollection test for the embedded driver.
  See also http://marc.theaimsgroup.com/?l=xindice-dev&m=106040091508016&w=2
  
  Revision  Changes    Path
  1.25      +12 -7     
xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java
  
  Index: CollectionImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- CollectionImpl.java       11 Dec 2003 11:48:54 -0000      1.24
  +++ CollectionImpl.java       12 Dec 2003 01:27:22 -0000      1.25
  @@ -353,8 +353,13 @@
               return null;
           }
   
  +        String parent = collPath.substring(0, collPath.lastIndexOf('/'));
  +        if ("".equals(parent)) {
  +            parent = "/";
  +        }
  +
           try {
  -            return new CollectionImpl(db, collPath.substring(0, 
collPath.lastIndexOf('/')));
  +            return new CollectionImpl(db, parent);
           } catch (XMLDBException e) {
               if (e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
                   // per getParentCollection contract, return null if no parent
  @@ -588,22 +593,22 @@
               final Object element = ns.getNextNode();
               if (element instanceof Node) {
                   Node n = (Node) element;
  -    
  +
                   if (n.getNodeType() == Node.DOCUMENT_NODE) {
                       n = ((Document) n).getDocumentElement();
                   }
  -    
  +
                   if (n instanceof DBNode) {
                       ((DBNode) n).expandSource();
                   }
  -    
  +
                   root.appendChild(doc.importNode(n, true));
               } else if (element instanceof Boolean || element instanceof 
Double) {
                   root.appendChild(doc.createTextNode(element.toString()));
               } else if (element instanceof String) {
                   root.appendChild(doc.createTextNode((String) element));
               } else {
  -                throw new XindiceRuntimeException("Unknown result type (" + 
element.getClass().getName() + "in nodeset");   
  +                throw new XindiceRuntimeException("Unknown result type (" + 
element.getClass().getName() + "in nodeset");
               }
   
               count++;
  
  
  

Reply via email to