Package nu.xom

Examples of nu.xom.Document


 
  private SimpleXQueryCommand() {}
 
  public static void main(String[] args) throws Exception {   
    String query = args[0];
    Document doc = null;
    if (args.length > 1) doc = new Builder().build(new File(args[1]));
   
    XQuery xquery;
    if (query.startsWith("{") && query.endsWith("}")) {
      // query is given inline between curly brackets, ala Saxon command line tool
View Full Code Here


  /** Runs the benchmark */
  public static void main(String[] args) throws Exception {
    int iters = Integer.parseInt(args[0]); // e.g. 1000
    int runs = Integer.parseInt(args[1])// e.g. 3
    Document doc = new Builder().build(new File(args[2])); // e.g. "data/samples/randj.xml"
    String path = args[3]; // e.g. "//line"
    String queryExpr = args[4]; // e.g. "Capul* thou"
   
    Analyzer textAnalyzer = PatternAnalyzer.DEFAULT_ANALYZER;
    Analyzer queryAnalyzer = PatternAnalyzer.DEFAULT_ANALYZER;
View Full Code Here

     * @param config the Saxon configuration (which among other things provides access to the NamePool)
     * @return the wrapper, which must implement DocumentInfo
     */

    public DocumentInfo wrapDocument(Object node, String baseURI, Configuration config) {
        Document documentNode = ((Node)node).getDocument();
        return new DocumentWrapper(documentNode, baseURI, config);
    }
View Full Code Here

    final DocumentURIResolver myResolver = resolver;
    config.setURIResolver(
      new URIResolver() {
        public Source resolve(String href, String baseURI) throws TransformerException {
          try {
            Document doc = myResolver.resolve(href, baseURI);
            if (doc == null) { // fallback to default mechanism
              doc = new DefaultDocumentURIResolver(config).resolve(href, baseURI);
            }
            return wrap(doc, null);
          } catch (ParsingException e) {
View Full Code Here

        File[] files = (File[]) value;
        ArrayList sources = new ArrayList(files.length);
        Builder builder = BuilderPool.GLOBAL_POOL.getBuilder(false);
        for (int i = 0; i < files.length; i++) {
          if (!files[i].isDirectory()) {
            Document doc;
            try {
              doc = builder.build(files[i]);
            } catch (Exception e) {
              throw new TransformerException(e);
            }
View Full Code Here

        System.setErr(systemErr);
    }
   
    public void testAllNodesQuery() {
       
        Document doc = new Document(new Element("doc"));
        Nodes subset = doc.query("//. | /");
        assertEquals(2, subset.size());
       
    }
View Full Code Here

<x>4</x>
</a> */
    public void testDescendantAxisOrder() {
       
        Element a = new Element("a");
        Document doc = new Document(a);
        Element x1 = new Element("x");
        x1.appendChild("a1");
        Element x2 = new Element("x");
        x2.appendChild("b2");
        Element x3 = new Element("x");
        x3.appendChild("c3");
        Element x4 = new Element("x");
        x4.appendChild("d4");
        a.appendChild(x1);
        Element b = new Element("b");
        b.appendChild(x2);
        b.appendChild(x3);
        a.appendChild(b);
        a.appendChild(x4);
        Nodes result = doc.query("//x");
        assertEquals(4, result.size());
        assertTrue(result.get(0) instanceof Element);
        assertTrue(result.get(1) instanceof Element);
        assertTrue(result.get(2) instanceof Element);
        assertTrue(result.get(3) instanceof Element);
View Full Code Here

    }
   

    public void testLongs() {
       
        Document doc = new Document(new Element("root"));
       
        Nodes result = doc.query("/*[5000000000=5000000000]");
        assertEquals(1, result.size());
       
        result = doc.query("/*[5000000000 < 5000000001]");
        assertEquals(1, result.size());
        result = doc.query("/*[5000000000 > 5000000001]");
        assertEquals(0, result.size());
        result = doc.query("/*[5000000001 >= 5000000001]");
        assertEquals(1, result.size());
        result = doc.query("/*[5000000001 > 5000000001]");
        assertEquals(0, result.size());
       
    }
View Full Code Here

   

    public void testNamespaceNodeParent() {
       
        Element root = new Element("root");
        Document doc = new Document(root);
        Element child = new Element("pre:child", "http://www.ietf.org");
        root.appendChild(child);
       
        Nodes result = doc.query("/root/*/namespace::*/parent::*");
        assertEquals(1, result.size());
        assertEquals(child, result.get(0));
       
    }
View Full Code Here

   

    public void testNamespaceNodeChild() {
       
        Element root = new Element("root");
        Document doc = new Document(root);
        Element child = new Element("pre:child", "http://www.ietf.org");
        root.appendChild(child);
       
        Nodes result = doc.query("/root/*/namespace::*/child::*");
        assertEquals(0, result.size());
       
    }
View Full Code Here

TOP

Related Classes of nu.xom.Document

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.