Package nu.xom

Examples of nu.xom.Elements


  }
 
  public static void listChildren(Element current) {
  
    inspect(current);
    Elements children = current.getChildElements();
    for (int i = 0; i < children.size(); i++) {
      listChildren(children.get(i));
    }
   
  }
View Full Code Here


            chapter++;
            exampleNumber = 0;
            list(root);   
        }
        else {
            Elements elements = root.getChildElements();
            for (int i = 0; i < elements.size(); i++) {
                Element child = elements.get(i);
                if (child.getLocalName().equals("chapter")) {
                    chapter++;
                    exampleNumber = 0;
                    findExamples(child);   
                }
View Full Code Here

   
    private static int exampleNumber = 0;
 
    private static void findExamples(Element element) {       

        Elements elements = element.getChildElements();
        for (int i = 0; i < elements.size(); i++) {
            Element child = elements.get(i);
             if (child.getQualifiedName().equals("example")) {
                printExample(child);
            }
            else {
                findExamples(child);   
View Full Code Here

            for (int i = 0; i < element.getNamespaceDeclarationCount(); i++) {
                String prefix = element.getNamespacePrefix(i);
                element.removeNamespaceDeclaration(prefix)
            }
           
            Elements elements = element.getChildElements();     
            for (int i = 0; i < elements.size(); i++) {
                strip(elements.get(i));
            }    
           
        }
        else {
            element.detach();    
View Full Code Here

            Element fault = responseBody.getFirstChildElement(
             "Fault", "http://schemas.xmlsoap.org/soap/envelope/");
            if (fault == null) { // no fault
                Element responseNumbers = responseBody.getFirstChildElement(
                 "Fibonacci_Numbers", "http://namespaces.cafeconleche.org/xmljava/ch3/");
                Elements results = responseNumbers.getChildElements("fibonacci",
                 "http://namespaces.cafeconleche.org/xmljava/ch3/");
                for (int i = 0; i < results.size(); i++) {
                    System.out.println(results.get(i).getValue());   
                }
            }
            else {
                handleFault(fault);
            }  
View Full Code Here

                    + "} "
                    + element.getQualifiedName();
        }

        MutableTreeNode node = new DefaultMutableTreeNode(data);
        Elements children = element.getChildElements();
        for (int i = 0; i < children.size(); i++) {
            node.insert(processElement(children.get(i)), i);
        }

        return node;

    }
View Full Code Here

  public static void qualify(Element current) {
  
    if (current.getNamespaceURI().equals("")) {
        current.setNamespaceURI("http://www.w3.org/1999/xhtml");
    }
    Elements children = current.getChildElements();
    for (int i = 0; i < children.size(); i++) {
      qualify(children.get(i));
    }
   
  }
View Full Code Here

    public void testJaxenIntegrationTest() throws ParsingException, IOException {
       
        Builder builder = new Builder();
        Document testDoc = builder.build(
          "http://cvs.jaxen.codehaus.org/viewrep/~raw,r=HEAD/jaxen/jaxen/xml/test/tests.xml");
        Elements documents = testDoc.getRootElement().getChildElements("document");
        for (int i = 0; i < documents.size(); i++) {
            Element documentElement = documents.get(i);
            String url = documentElement.getAttributeValue("url");
            Document source = builder.build(
              "http://cvs.jaxen.codehaus.org/viewrep/~raw,r=HEAD/jaxen/jaxen/"
              + url);
            Elements contextElements = documentElement.getChildElements("context");
            for (int j = 0; j < contextElements.size(); j++) {
                Element contextElement = contextElements.get(j);
                   
                // skip tests that use variables
                // because XOM doesn't support variables in
                // XPath expressions
                if (queryUsesVars(contextElement)) continue;
               
                String xpath = contextElement.getAttributeValue("select");
                XPathContext namespaces = getXPathContext(contextElement);
                Node context = source.query(xpath).get(0);
               
                // process counts
                Elements tests = contextElement.getChildElements("test");
                for (int k = 0; k < tests.size(); k++) {
                    Element test = tests.get(k);
                   
                    String select = test.getAttributeValue("select");
                    Attribute countAttribute = test.getAttribute("count");
                    int count = -1;
                    if (countAttribute != null) {
                        count = Integer.parseInt(countAttribute.getValue());
                    }
                   
                    boolean exceptional = false;
                    String exception = test.getAttributeValue("exception");
                    if ("true".equals(exception)) {
                        exceptional = true;
                    }
                   
                    if (exceptional) {
                        try {
                            context.query(select, namespaces);
                            fail("Evaluated " + select);
                        }
                        catch (XPathException success) {
                            assertNotNull(success.getMessage());
                        }
                    }
                    else {
                        try {
                            Nodes results = context.query(select, namespaces);
                            if (count != -1) {
                                assertEquals(select, count, results.size());
                            }
                            Elements valueOfs = test.getChildElements("valueOf");
                            for (int v = 0; v < valueOfs.size(); v++) {
                                Element vo = valueOfs.get(v);
                                checkValueOf(results.get(0), vo, namespaces);
                            }
                        }
                        catch (XPathException ex) {
                            if (ex.getMessage().equalsIgnoreCase("XPath error: No such function document")
                              || ex.getMessage().equalsIgnoreCase("XPath error: No such function evaluate")) {
                                continue;
                            }
                            throw ex;
                        }

                    }
                }
               
                // process valueOfs
                Elements valueOfs = contextElement.getChildElements("valueOf");
                for (int k = 0; k < valueOfs.size(); k++) {
                    checkValueOf(context, valueOfs.get(k), namespaces);
                }
               
            }
        }
    }
View Full Code Here

        // The test suite need 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 submitters = testsuite.getChildElements("test-catalog");
            for (int i = 0; i < submitters.size(); i++) {
                Element submitter = submitters.get(i);
                Elements testcases = submitter.getChildElements("test-case");
                for (int j = 0; j < testcases.size(); j++) {
                   
                    Element testcase = testcases.get(j);
                    String id = testcase.getAttributeValue("id");
                    if (id.startsWith("output_")) {
                        // These test cases are mostly about producing
                        // HTML and plain text output that isn't
                        // relevant to XOM
                        continue;
                    }
                    File root = new File(base, testcase.getFirstChildElement("file-path").getValue());
                    File input = null;
                    File style = null;
                    File output = null;
                    Element scenario = testcase.getFirstChildElement("scenario");
                    Elements inputs = scenario.getChildElements("input-file");
                    for (int k = 0; k < inputs.size(); k++) {
                        Element file = inputs.get(k);
                        String role = file.getAttributeValue("role");
                        if ("principal-data".equals(role)) {
                            input = new File(root, file.getValue());
                        }
                        else if ("principal-stylesheet".equals(role)) {
                            style = new File(root, file.getValue());
                        }
                    }
                    Elements outputs = scenario.getChildElements("output-file");
                    for (int k = 0; k < outputs.size(); k++) {
                        Element file = outputs.get(k);
                        String role = file.getAttributeValue("role");
                        if ("principal".equals(role)) {
                            // Fix up OASIS catalog bugs
                            File parent = new File(root.getParent());
                            parent = new File(parent, "REF_OUT");
View Full Code Here

        // The test suite need 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 submitters = testsuite.getChildElements("test-catalog");
            Element submitter = submitters.get(1);
            Elements testcases = submitter.getChildElements("test-case");
            for (int j = 0; j < testcases.size(); j++) {
                Element testcase = testcases.get(j);
                String id = testcase.getAttributeValue("id");
                File root = new File(base, "MSFT_Conformance_Tests");
                root = new File(root, testcase.getFirstChildElement("file-path").getValue());
                File input = null;
                File style = null;
                File output = null;
                Element scenario = testcase.getFirstChildElement("scenario");
                Elements inputs = scenario.getChildElements("input-file");
                for (int k = 0; k < inputs.size(); k++) {
                    Element file = inputs.get(k);
                    String role = file.getAttributeValue("role");
                    if ("principal-data".equals(role)) {
                        input = new File(root, file.getValue());
                    }
                    else if ("principal-stylesheet".equals(role)) {
                        style = new File(root, file.getValue());
                    }
                }  // end for
                Elements outputs = scenario.getChildElements("output-file");
                for (int k = 0; k < outputs.size(); k++) {
                    Element file = outputs.get(k);
                    String role = file.getAttributeValue("role");
                    if ("principal".equals(role)) {
                        // Fix up OASIS catalog bugs
                        File parent = new File(root.getParent());
                        parent = new File(parent, "REF_OUT");
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.