Package org.apache.xindice.xml.dom

Examples of org.apache.xindice.xml.dom.DocumentImpl


    */
   public Resource getMembersAsResource() throws XMLDBException {
      // This impl works but it would be nice if we just got the result set from
      // the server in this format instead of having to build it. Right now it's
      // pretty innefficient
      Document doc = new DocumentImpl();

      Element set = doc.createElementNS(RESOURCE_SET_NS, "xapi:resourceSet");
      set.setAttributeNS(RESOURCE_SET_NS, "xapi:collectionURI",
         "xmldb:xindice://" + ((XindiceCollection) collection).getCanonicalName());
      set.setAttribute("xmlns:xapi", RESOURCE_SET_NS);
      doc.appendChild(set);

      int i = 0;
      while ( i < resources.size() ) {
         XMLResource res = (XMLResource) resources.get(i);
         Element resource = doc.createElementNS(RESOURCE_SET_NS,
            "xapi:resource");
         resource.setAttributeNS(RESOURCE_SET_NS, "xapi:documentID",
            res.getDocumentId());

         resource.appendChild(doc.importNode(
            ((Document) res.getContentAsDOM()).getDocumentElement(), true));

         set.appendChild(resource);

         i++;
View Full Code Here


            }
            else {
               xu.execute(context);
            }

            DocumentImpl doc = new DocumentImpl();
            Element elem = doc.createElementNS(NodeSource.SOURCE_NS, "src:"+NodeSource.SOURCE_MODIFIED);
            elem.setAttribute(NodeImpl.XMLNS_PREFIX+":src", NodeSource.SOURCE_NS);
            doc.appendChild(elem);
            Text count = doc.createTextNode(Integer.toString(xu.getModifiedCount()));
            elem.appendChild(count);
           
            return new NodeListSet(doc.getChildNodes());
         }
         catch ( Exception e ) {
            if( e instanceof QueryException ) {
               throw (QueryException) e.fillInStackTrace();
            }
View Full Code Here

    } catch (Exception e) {
      fail("Can't parse xml document! "+e.getMessage());
    }
    MetaData meta = new MetaData();
    meta.streamFromXML(doc.getDocumentElement(), true);
    Document doc2 = new DocumentImpl();
    meta.streamToXML(doc2, true);
    assertEquals(TextWriter.toString(doc), TextWriter.toString(doc2));
  }
View Full Code Here

      try {
         doc = DOMParser.toDocument(xml);

         // Have to move it to Xindice DOM for XMLObject AutoLinking
         byte[] b = DOMCompressor.Compress(doc, symbols);
         doc = new DocumentImpl(b, symbols, new NodeSource(this, key));

         if ( documentCache != null )
            documentCache.putDocument(this, key, b);
      }
      catch ( Exception e ) {
View Full Code Here

      if ( compressed ) {
         try {
            byte[] b = DOMCompressor.Compress(document, symbols);
            value = new Value(b);

            document = new DocumentImpl(b, symbols, new NodeSource(this, key));
         }
         catch ( Exception e ) {
            throw new DBException(FaultCodes.COL_CANNOT_STORE, "Error storing Document '"+key+"'", e);
         }
      } else {
View Full Code Here

            return null;

         Value value = record.getValue();

         if ( compressed ) {
            doc = new DocumentImpl(value.getData(), symbols, new NodeSource(this, key));

            if ( documentCache != null )
               documentCache.putDocument(this, key, value.getData());
         }
         else
View Full Code Here

      return null;
   }

   private void putObject(Key key, XMLSerializable obj /*, boolean create */) throws DBException {
      Document doc = new DocumentImpl();
      ProcessingInstruction pi = doc.createProcessingInstruction(CLASSNAME, obj.getClass().getName());
      doc.appendChild(pi);
      Element elem = obj.streamToXML(doc);
      doc.appendChild(elem);
      putDocument(key, doc /*, create */);
   }
View Full Code Here

    * @return The Content value
    * @exception XMLDBException
    */
   public Object getContent() throws XMLDBException {
      if ( bytes != null ) {
         DocumentImpl doc = new DocumentImpl(bytes, symbols, null);
         return TextWriter.toString(doc);
      }
      else
         return content;
   }
View Full Code Here

    * @exception XMLDBException
    */
   public Node getContentAsDOM() throws XMLDBException {
      try {
         if ( bytes != null )
            return new DocumentImpl(bytes, symbols, null);
         else
            return DOMParser.toDocument(content);
      }
      catch (Exception e) {
         throw FaultCodes.createXMLDBException(e);
View Full Code Here

            Key key = rec.getKey();
            Value val = rec.getValue();
            if ( val.getData() != null ) {
               try {
                  if ( compressed ) {
                     Document doc = new DocumentImpl(val.getData(), symbols, new NodeSource(Collection.this, key));
                     return new ColContainer(key, doc);
                  }
                  else
                     return new ColContainer(key, DOMParser.toDocument(val));
               }
View Full Code Here

TOP

Related Classes of org.apache.xindice.xml.dom.DocumentImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.