Package nu.xom

Examples of nu.xom.XPathContext


      }
    }
   
    if(doc == null) return results;
   
    XPathContext xpc = new XPathContext("y", "urn:yahoo:srch");
   
    Nodes n = doc.query("//y:Summary", xpc);

    for(int i=0;i<n.size();i++) {
      String resStr = n.get(i).getValue();
View Full Code Here


    url = url + "&set=" + "beilstein";
    System.out.println("Fetching " + url);
    Document doc = new Builder().build(url);
    System.out.println("Fetched!");
    //new Serializer(System.out).write(doc);
    XPathContext xpc = new XPathContext();
    xpc.addNamespace("oai", "http://www.openarchives.org/OAI/2.0/");
    xpc.addNamespace("art", "http://dtd.nlm.nih.gov/2.0/xsd/archivearticle");
   
    while(doc != null) {
      Nodes paperNodes = doc.query("/oai:OAI-PMH/oai:ListRecords/oai:record/oai:metadata/art:article", xpc);
      System.out.println("Found " + paperNodes.size() + " papers");
      for(int i=0;i<paperNodes.size();i++) {
View Full Code Here

      Element nameElem = new Element("name");
      nameElem.appendChild(name);
      cmlMolElem.insertChild(nameElem, 0);
    }
   
    Nodes n = cmlMolElem.query(".//cml:label", new XPathContext("cml", "http://www.xml-cml.org/schema"));
    for(int i=0;i<n.size();i++){
      n.get(i).detach();
    }
  }
View Full Code Here

            composerFactory.addImport("com.habitsoft.kiyaa.util.*");
        }

        private Element getComponentRootElement(Document d) {
            Element rootElement = d.getRootElement();
            XPathContext context = new XPathContext("k", KIYAA_CORE_TAGS_NAMESPACE);
            Nodes components = d.query("//k:view", context);
            if (components.size() > 0) {
                if (components.size() > 1) {
                    logger.log(TreeLogger.WARN, "Found more than one component; only the first will be used", null);
                }
View Full Code Here

        String expected = "<child312 xmlns=\"http://www.example.org/\"></child312>";

        try {
            Canonicalizer serializer = new Canonicalizer(out,
              Canonicalizer.EXCLUSIVE_XML_CANONICALIZATION);
            XPathContext context = new XPathContext("pre", "http://www.example.org/");
            serializer.write(doc.query("/*/pre:child312 | /*/pre:child312/namespace::node()",
             context));
        }
        finally {
            out.close();
View Full Code Here

        root.appendChild(new Element("pre:child312", "http://www.example.org/"));
       
        String expected = "<pre:child312 xmlns:pre=\"http://www.example.org/\"></pre:child312>";

        try {
            XPathContext context = new XPathContext("pre", "http://www.example.org/");
            Canonicalizer serializer = new Canonicalizer(out,
          Canonicalizer.EXCLUSIVE_XML_CANONICALIZATION);
            serializer.write(doc.query("/*/pre:child312 | /*/pre:child312/namespace::node()", context));
        }
        finally {
View Full Code Here

            + "      </e2>\n"
            + "   </e1>\n"
            + "</doc>";
       
        Document doc = builder.build(input, null);
        XPathContext context = new XPathContext("ietf", "http://www.ietf.org");
        String xpath = "(//. | //@* | //namespace::*)\n"
            + "[\n"
            + "self::ietf:e1 or (parent::ietf:e1 and not(self::text() or self::e2))"
            + " or\n"
            + " count(id(\"E3\")|ancestor-or-self::node()) = count(ancestor-or-self::node())\n"
View Full Code Here

            + "      </e2>\n"
            + "   </e1>\n"
            + "</doc>";
       
        Document doc = builder.build(input, null);
        XPathContext context = new XPathContext("ietf", "http://www.ietf.org");
        String xpath = "//aaa";
        try {
            Canonicalizer serializer = new Canonicalizer(out, false);
            serializer.write(doc.query(xpath, context));
        }
View Full Code Here

            + "      </e2>\n"
            + "   </e1>\n"
            + "</doc>";
       
        Document doc = builder.build(input, null);
        XPathContext context = new XPathContext("ietf", "http://www.ietf.org");
        String xpath = "//* | //text() | //@* | //namespace::*";
       
        try {
            Canonicalizer serializer = new Canonicalizer(out, false);
            serializer.write(doc.query(xpath, context));
View Full Code Here

            + "      </e2>\n"
            + "   </e1>\n"
            + "</doc><!-- epilog -->";
       
        Document doc = builder.build(input, null);
        XPathContext context = new XPathContext("ietf", "http://www.ietf.org");
        String xpath = "(/*//. | //@* | //namespace::*)\n"
            + "[\n"
            + "self::ietf:e1 or (parent::ietf:e1 and not(self::text() or self::e2))"
            + " or\n"
            + " count(id(\"E3\")|ancestor-or-self::node()) = count(ancestor-or-self::node())\n"
View Full Code Here

TOP

Related Classes of nu.xom.XPathContext

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.