Package org.xmldb.api.modules

Examples of org.xmldb.api.modules.XMLResource


   */
  public void insert(Element pElement) throws PMException {
    try {
      Collection col = getXmlDbCollection();
      String id = getId(pElement);
      XMLResource resource = (XMLResource) col.createResource(id, XMLResource.RESOURCE_TYPE);
      ContentHandler ch = resource.setContentAsSAX();
      Marshaller marshaller = getManager().getFactory().createMarshaller();
      marshaller.marshal(pElement, ch);
      col.storeResource(resource);
    } catch (XMLDBException e) {
      throw new PMException(e);
View Full Code Here


   */
  public void update(Element pElement) throws PMException {
    try {
      Collection col = getXmlDbCollection();
      String id = getId(pElement);
      XMLResource resource = (XMLResource) col.getResource(id);
      ContentHandler ch = resource.setContentAsSAX();
      Marshaller marshaller = getManager().getFactory().createMarshaller();
      marshaller.marshal(pElement, ch);
      col.storeResource(resource);
    } catch (XMLDBException e) {
      throw new PMException(e);
View Full Code Here

   */
  public void delete(Element pElement) throws PMException {
    try {
     Collection col = getXmlDbCollection();
     String id = getId(pElement);
     XMLResource resource = (XMLResource) col.createResource(id, XMLResource.RESOURCE_TYPE);
     col.removeResource(resource);
   } catch (XMLDBException e) {
     throw new PMException(e);
   } catch (IllegalAccessException e) {
     throw new PMException(e);
View Full Code Here

            collection = DatabaseManager.getCollection(col, user, password);
            if (collection == null) {
                throw new ResourceNotFoundException("Document " + url + " not found");
            }

            XMLResource xmlResource = (XMLResource) collection.getResource(res);
            if (xmlResource == null) {
                throw new ResourceNotFoundException("Document " + url + " not found");
            }

            if (query != null) {
                // Query resource
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Querying resource " + res + " from collection " + url + "; query= " + this.query);
                }

                queryToSAX(handler, collection, res);
            } else {
                // Return entire resource
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Obtaining resource " + res + " from collection " + col);
                }

                xmlResource.getContentAsSAX(handler);
            }
        } catch (XMLDBException xde) {
            String error = "Unable to fetch content. Error "
                           + xde.errorCode + ": " + xde.getMessage();
            throw new SAXException(error, xde);
View Full Code Here

            IncludeXMLConsumer includeHandler = new IncludeXMLConsumer(handler);

            // Print search results
            ResourceIterator results = resultSet.getIterator();
            while (results.hasMoreResources()) {
                XMLResource result = (XMLResource)results.nextResource();

                final String id = result.getId();
                final String documentId = result.getDocumentId();

                attributes.clear();
                if (id != null) {
                    attributes.addAttribute("", RESULT_ID_ATTR, RESULT_ID_ATTR,
                                            CDATA, id);
                }
                if (documentId != null) {
                    attributes.addAttribute("", RESULT_DOCID_ATTR, RESULT_DOCID_ATTR,
                                            CDATA, documentId);
                }

                handler.startElement(URI, RESULT, QRESULT, attributes);
                result.getContentAsSAX(includeHandler);
                handler.endElement(URI, RESULT, QRESULT);
            }

            handler.endElement(URI, RESULTSET, QRESULTSET);
            handler.endPrefixMapping(PREFIX);
View Full Code Here

        try {
            collection = DatabaseManager.getCollection(col, user, password);
            if (collection == null) {
                result = false;
            } else {
                XMLResource xmlResource = (XMLResource) collection.getResource(res);
                if (xmlResource == null) {
                    result = false;
                }
            }
        } catch (XMLDBException xde) {
View Full Code Here

        // Create an XObject to be used in Xpath query
        xo = new XObject();

        // Retrieve the next node
        XMLResource resource = (XMLResource) results.nextResource();

        originalnode = resource.getContentAsDOM();

      }
      catch (Exception e) {
        getLogger ().debug ("DBXMLAUTH: error creating XObject ");
      }
View Full Code Here

            collection = DatabaseManager.getCollection(col, user, password);
            if (collection == null) {
                throw new ResourceNotFoundException("Document " + url + " not found");
            }

            XMLResource xmlResource = (XMLResource) collection.getResource(res);
            if (xmlResource == null) {
                throw new ResourceNotFoundException("Document " + url + " not found");
            }

            if (query != null) {
                // Query resource
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Querying resource " + res + " from collection " + url + "; query= " + this.query);
                }

                queryToSAX(handler, collection, res);
            } else {
                // Return entire resource
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Obtaining resource " + res + " from collection " + col);
                }

                xmlResource.getContentAsSAX(handler);
            }
        } catch (XMLDBException xde) {
            String error = "Unable to fetch content. Error "
                           + xde.errorCode + ": " + xde.getMessage();
            throw new SAXException(error, xde);
View Full Code Here

            IncludeXMLConsumer includeHandler = new IncludeXMLConsumer(handler);

            // Print search results
            ResourceIterator results = resultSet.getIterator();
            while (results.hasMoreResources()) {
                XMLResource result = (XMLResource)results.nextResource();

                final String id = result.getId();
                final String documentId = result.getDocumentId();

                attributes.clear();
                if (id != null) {
                    attributes.addAttribute("", RESULT_ID_ATTR, RESULT_ID_ATTR,
                        CDATA, id);
                }
                if (documentId != null) {
                    attributes.addAttribute("", RESULT_DOCID_ATTR, RESULT_DOCID_ATTR,
                        CDATA, documentId);
                }
                handler.startElement(URI, RESULT, QRESULT, attributes);

                result.getContentAsSAX(includeHandler);

                handler.endElement(URI, RESULT, QRESULT);
            }

            handler.endElement(URI, RESULTSET, QRESULTSET);
View Full Code Here

        if (i.hasMoreResources()) {
          Class c = getManager().getHandlerClass();
          JMHandler handler = (JMHandler) c.newInstance();
          handler.setObserver(pObserver);
          while(i.hasMoreResources()) {
            XMLResource r = (XMLResource) i.nextResource();
            r.getContentAsSAX(handler);
          }
        }
      }
    } catch (IllegalAccessException e) {
      throw new PMException(e);
View Full Code Here

TOP

Related Classes of org.xmldb.api.modules.XMLResource

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.