Package org.xmldb.api.base

Examples of org.xmldb.api.base.ResourceSet


        AttributesImpl attributes = new AttributesImpl();

        try {
            XPathQueryService service =
                (XPathQueryService) collection.getService("XPathQueryService", "1.0");
            ResourceSet resultSet = (resource == null) ?
                    service.query(query) : service.queryResource(resource, query);

            attributes.addAttribute("", QUERY_ATTR, QUERY_ATTR, "CDATA", query);
            attributes.addAttribute("", RESULTS_COUNT_ATTR,
                    RESULTS_COUNT_ATTR, "CDATA", Long.toString(resultSet.getSize()));

            handler.startDocument();
            handler.startPrefixMapping(PREFIX, URI);
            handler.startElement(URI, RESULTSET, QRESULTSET, attributes);

            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();
View Full Code Here


            }
           
            service = (XPathQueryService)col.getService("XPathQueryService","1.0");
            addNamespaces(service, (String)table.get("namespaces"));
           
            ResourceSet resultSet = service.query(querystring);
            results = resultSet.getIterator();
           
            while (results.hasMoreResources() ) {
                XMLResource resource = (XMLResource)results.nextResource();
                String documentstr = (String)resource.getContent();
                System.out.println(documentstr);
View Full Code Here

  * Main invocation routine.
  */
  public Map act (Redirector redirector, SourceResolver resolver, Map objectModel, String src,
        Parameters parameters) throws Exception {

    ResourceSet rs = null;

    // read global parameter settings
    boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;

    if (this.settings.containsKey("reloadable")) {
View Full Code Here

  }


  private ResourceSet Authenticate( Configuration conf, Request req) throws Exception, XMLDBException {

     ResourceSet rs = null;

    String query = this.getAuthQuery (conf, req);
    if (query == null) {
      getLogger ().debug ("DBXMLAUTH: have not got query");
      req.setAttribute("message", "The authenticator is misconfigured");
      return null;
    }
    getLogger ().debug ("DBXMLAUTH: query is: " + query);


    Collection col = CreateConnection( conf );

    if ( col != null )
    {
      if ( col.isOpen() )
      {

        try
        {
          XPathQueryService service = (XPathQueryService) col.getService("XPathQueryService", "1.0");

          rs = service.query(query);
          ResourceIterator results = rs.getIterator();

          if (results.hasMoreResources() == false)
          {
              getLogger ().debug ("DBXMLAUTH: auth failed");
              return null;
View Full Code Here

        AttributesImpl attributes = new AttributesImpl();

        try {
            XPathQueryService service =
                (XPathQueryService) collection.getService("XPathQueryService", "1.0");
            ResourceSet resultSet = (resource == null) ?
                    service.query(query) : service.queryResource(resource, query);

            attributes.addAttribute("", QUERY_ATTR, QUERY_ATTR, "CDATA", query);
            attributes.addAttribute("", RESULTS_COUNT_ATTR,
                    RESULTS_COUNT_ATTR, "CDATA", Long.toString(resultSet.getSize()));

            handler.startDocument();
            handler.startPrefixMapping(PREFIX, URI);
            handler.startElement(URI, RESULTSET, QRESULTSET, attributes);

            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();
View Full Code Here

            }

            service = (XPathQueryService) col.getService("XPathQueryService", "1.0");
            addNamespaces(service, (String) table.get("namespaces"));

            ResourceSet resultSet = service.query(querystring);
            results = resultSet.getIterator();

            while (results.hasMoreResources()) {
                XMLResource resource = (XMLResource) results.nextResource();
                String documentstr = (String) resource.getContent();
                System.out.println(documentstr);
View Full Code Here

      collection = getCollection("xmldb:xindice:///db/addressbook");

      String xpath = "//person[fname='John']";
      XPathQueryService service = (XPathQueryService) collection.getService("XPathQueryService", "1.0");
      ResourceSet resourceSet = service.query(xpath);
      ResourceIterator resourceIterator = resourceSet.getIterator();

      while (resourceIterator.hasMoreResources()) {
        Resource resource = resourceIterator.nextResource();
        System.out.println((String) resource.getContent());
      }
View Full Code Here

  {
    String query = "//person[first='John' and last='Smith']";

    Collection col = this.client.getCollection(TEST_COLLECTION_PATH);
    XPathQueryService xpathservice = (XPathQueryService) col.getService("XPathQueryService", "1.0");
    ResourceSet resultSet = xpathservice.query(query);

    ResourceIterator results = resultSet.getIterator();

    List res = asList(results);
    assertEquals(1, res.size());

    XMLResource resource = (XMLResource) resultSet.getResource(0);

    String john =
      "<?xml version=\"1.0\"?>"
        + "<person xmlns:src='http://xml.apache.org/xindice/Query' src:col='/db/testing/current' src:key='doc1'>"
        + "<first>John</first>"
View Full Code Here

    Collection col = this.client.getCollection(TEST_COLLECTION_PATH);
    XPathQueryService xpathservice = (XPathQueryService) col.getService("XPathQueryService", "1.0");
    xpathservice.setNamespace("h", "http://example.net/person");

    ResourceSet resultSet = xpathservice.query(query);

    ResourceIterator results = resultSet.getIterator();
    List res = asList(results);
    assertEquals(1, res.size());

    XMLResource resource = (XMLResource) resultSet.getResource(0);

    // ensure that the resource has the correct doc id.
    assertEquals("doc3", resource.getDocumentId());

    Node node = resource.getContentAsDOM();
View Full Code Here

    Collection col = this.client.getCollection(TEST_COLLECTION_PATH);
    XPathQueryService xpathservice = (XPathQueryService) col.getService("XPathQueryService", "1.0");
    xpathservice.setNamespace("h", "http://example.net/person");

    ResourceSet resultSet = xpathservice.query(query);

    ResourceIterator results = resultSet.getIterator();
    List res = asList(results);
    assertEquals(1, res.size());

    XMLResource resource = (XMLResource) resultSet.getResource(0);
    Node node = resource.getContentAsDOM();
    String retrieved = TextWriter.toString(node);
    assertFalse("Namespace definitions imported deep in: " + retrieved, -1 == retrieved.indexOf("<p:first>"));

    // ensure that the resource has the correct doc id.
View Full Code Here

TOP

Related Classes of org.xmldb.api.base.ResourceSet

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.