Package nu.xom

Examples of nu.xom.Elements


        Builder builder = new Builder();
        Document doc = builder.build(
          "http://staff.science.uva.nl/~francesc/xpathmark/benchmark_canon.xml"
        );
        Element root = doc.getRootElement();
        Elements inputs = root.getChildElements("document");
        Element input = inputs.get(0).getFirstChildElement("site");
        input.detach();
       
        Nodes doc1Queries = root.query("child::query[starts-with(@id, 'Q')]");
       
        for (int i = 0; i < doc1Queries.size(); i++) {
View Full Code Here


        Builder builder = new Builder();
        Document doc = builder.build(
          "http://staff.science.uva.nl/~francesc/xpathmark/benchmark_canon.xml"
        );
        Element root = doc.getRootElement();
        Elements inputs = root.getChildElements("document");
        Element input = inputs.get(1);
        Document html = new Document(new Element("fake"));
        int p = 0;
        while (true) {
            Node node = input.getChild(0);
            if (node instanceof Element) break;
View Full Code Here

        File canonical = new File(data, "canonical");
        File masterList = new File(canonical, "xmlconf");
        masterList = new File(masterList, "xmlconf.xml");
        if (masterList.exists()) {
            Document xmlconf = builder.build(masterList);
            Elements testcases = xmlconf.getRootElement().getChildElements("TESTCASES");
            processTestCases(testcases);
        }

    }
View Full Code Here

    private void processTestCases(Elements testcases)
      throws ParsingException, IOException {
       
        for (int i = 0; i < testcases.size(); i++) {
              Element testcase = testcases.get(i);
              Elements tests = testcase.getChildElements("TEST");
              processTests(tests);
              Elements level2 = testcase.getChildElements("TESTCASES");
              // need to be recursive to handle recursive IBM test cases
              processTestCases(level2);
        }
       
    }
View Full Code Here

                if (child instanceof Element) strip((Element) child);
            }    
           
        }
        else {
            Elements elements = element.getChildElements();     
            for (int i = 0; i < elements.size(); i++) {
                strip(elements.get(i));
            }    
        }      
       
    }
View Full Code Here

      element.addAttribute(new Attribute("ID", "_" + id));
      id = id + 1;
    }
   
    // recursion
    Elements children = element.getChildElements();
    for (int i = 0; i < children.size(); i++) {
      processElement(children.get(i));  
    }
   
  }
View Full Code Here

       
        URL base = new URL("http://www.w3.org/XML/2005/01/xml-id/test-suite.xml");
        Builder builder = new Builder();
        Document catalog = builder.build(base.openStream());
        Element testsuite = catalog.getRootElement();
        Elements testCatalogs = testsuite.getChildElements("test-catalog");
        for (int i = 0; i < testCatalogs.size(); i++) {
            Elements testcases = testCatalogs.get(i).getChildElements("test-case");
            for (int j = 0; j < testcases.size(); j++) {
                Element testcase = testcases.get(j);
                String features = testcase.getAttributeValue("feature");
                if (features != null && features.indexOf("xml11") >= 0) {
                    continue; // skip test
                }
                URL testURL = new URL(base, testcase.getFirstChildElement("file-path").getValue() + "/");
                Element scenario = testcase.getFirstChildElement("scenario");
                Element input = scenario.getFirstChildElement("input-file");
                URL inputFile = new URL(testURL, input.getValue());
                Elements expectedIDs = scenario.getChildElements("id");
                Document inputDoc = builder.build(inputFile.openStream());
                Nodes recognizedIDs = getIDs(inputDoc);
                assertEquals(expectedIDs.size(), recognizedIDs.size());
                for (int k = 0; k < expectedIDs.size(); k++) {
                    assertEquals(expectedIDs.get(i).getValue(), recognizedIDs.get(i).getValue());
                }
            } // end for
        }
       
    }
View Full Code Here

        // The test suite needs to be installed separately. If we can't
        // find the catalog, we just don't run these tests.
        if (catalog.exists()) {
            Document doc = builder.build(catalog);
            Element testsuite = doc.getRootElement();
            Elements testCatalogs = testsuite.getChildElements("test-catalog");
            for (int i = 0; i < testCatalogs.size(); i++) {
                Elements testcases = testCatalogs.get(i).getChildElements("test-case");
                for (int j = 0; j < testcases.size(); j++) {
                    Element testcase = testcases.get(j);
                    String features = testcase.getAttributeValue("features");
                    if (features != null && features.indexOf("xml11") >= 0) {
                        continue; // skip test
                    }
                    File root = new File(base, testcase.getFirstChildElement("file-path").getValue());
                    File inputFile = null;
                    Element scenario = testcase.getFirstChildElement("scenario");
                    Element input = scenario.getFirstChildElement("input");
                    inputFile = new File(root, input.getValue());
                    Elements expectedIDs = scenario.getChildElements("id");
                    try {
                        Document inputDoc = builder.build(inputFile);
                        Nodes recognizedIDs = getIDs(inputDoc);
                        assertEquals(expectedIDs.size(), recognizedIDs.size());
                        for (int k = 0; k < expectedIDs.size(); k++) {
                            assertEquals(expectedIDs.get(i).getValue(), recognizedIDs.get(i).getValue());
                        }
                    }
                    catch (ParsingException ex) {
                        System.err.println(inputFile);
                        ex.printStackTrace();
View Full Code Here

     
        File masterList = new File(canonical, "xmlconf");
        masterList = new File(masterList, "xmlconf.xml");
        if (masterList.exists()) {
            Document xmlconf = builder.build(masterList);
            Elements testcases = xmlconf.getRootElement().getChildElements("TESTCASES");
            processTestCases(testcases);
        }

    }
View Full Code Here

    private void processTestCases(Elements testcases)
      throws ParsingException, IOException {
       
        for (int i = 0; i < testcases.size(); i++) {
              Element testcase = testcases.get(i);
              Elements tests = testcase.getChildElements("TEST");
              processTests(tests);
              Elements level2 = testcase.getChildElements("TESTCASES");
              // need to be recursive to handle recursive IBM test cases
              processTestCases(level2);
        }
       
    }
View Full Code Here

TOP

Related Classes of nu.xom.Elements

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.