Package nu.xom

Examples of nu.xom.XPathContext$JaxenNamespaceContext


        Element child = new Element("child", "http://www.example.org");
        parent.appendChild(child);
        child.appendChild("1");
        child.appendChild("2");
       
        XPathContext context = new XPathContext("pre", "http://www.example.org");
        Nodes result = parent.query("descendant::text()", context);
        assertEquals(2, result.size());
        assertEquals("1", result.get(0).getValue());  
        assertEquals("2", result.get(1).getValue());  
       
View Full Code Here


                // 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++) {
View Full Code Here

    }


    private XPathContext getXPathContext(Element contextElement) {

        XPathContext context = new XPathContext();
        for (int i = 0; i < contextElement.getNamespaceDeclarationCount(); i++) {
            String prefix = contextElement.getNamespacePrefix(i);
            if (! "".equals(prefix)) {
                context.addNamespace(prefix, contextElement.getNamespaceURI(prefix));
            }
        }
        return context;
    }
View Full Code Here

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        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

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

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        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";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        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::*";
       
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out, false);
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

            + "      </e2>\n"
            + "   </e1>\n"
            + "</doc>";
       
        Document doc = builder.build(input, null);
        XPathContext context = new XPathContext("ietf", "http://www.ietf.org");
        String xpath = "(/* | /*/namespace::*)\n";
       
        String expected = "<doc xmlns=\"http://www.ietf.org\" xmlns:w3c=\"http://www.w3.org\"></doc>";

        ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

TOP

Related Classes of nu.xom.XPathContext$JaxenNamespaceContext

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.