Package org.apache.excalibur.xml.xpath

Examples of org.apache.excalibur.xml.xpath.XPathProcessor.selectSingleNode()


                    String xpath = bindingElm.getAttribute("xpath");
                    if (!xpath.equals("")) {
                        XPathProcessor xpathProcessor = (XPathProcessor)manager.lookup(XPathProcessor.ROLE);
                        try {
                            Node node = xpathProcessor.selectSingleNode(document, xpath);
                            if (node == null)
                                throw new BindingException("XPath expression \"" + xpath + "\" didn't return a result.");
                            if (!(node instanceof Element))
                                throw new BindingException("XPath expression \"" + xpath + "\" did not return an element node.");
                            element = (Element)node;
View Full Code Here


            Document document1 = parser.parseDocument(new InputSource(new StringReader(CONTENT1)));
            Document document2 = parser.parseDocument(new InputSource(new StringReader(CONTENT2)));

            // 1. Test single node expression
            String expr = "/test:root/test:element1";
            Node node = processor.selectSingleNode(document1, expr);
            assertNotNull("Must select <test:element1/> node, but got null", node);
            assertEquals("Must select <test:element1/> node", Node.ELEMENT_NODE, node.getNodeType());
            assertEquals("Must select <test:element1/> node", "element1", node.getLocalName());

            // 2. Test single node expression with no expected result
View Full Code Here

            assertEquals("Must select <test:element1/> node", Node.ELEMENT_NODE, node.getNodeType());
            assertEquals("Must select <test:element1/> node", "element1", node.getLocalName());

            // 2. Test single node expression with no expected result
            expr = "/test:root/test:element3";
            node = processor.selectSingleNode(document1, expr);
            assertNull("Must be null", node);

            // 3. Test multiple node expression
            expr = "/test:root/test:*";
            NodeList list = processor.selectNodeList(document1, expr);
View Full Code Here

            boolean bool = processor.evaluateAsBoolean(document1, expr);
            assertEquals(true, bool);

            // 7. Test expression in the root element context
            expr = "/test:root/test:element1";
            node = processor.selectSingleNode(document1.getDocumentElement(), expr);
            assertNotNull("Must select <test:element1/> node, but got null", node);
            assertEquals("Must select <test:element1/> node", Node.ELEMENT_NODE, node.getNodeType());
            assertEquals("Must select <test:element1/> node", "element1", node.getLocalName());

            // 8. Test expression in the child node context
View Full Code Here

            assertNotNull("Must select <test:element1/> node, but got null", node);
            assertEquals("Must select <test:element1/> node", Node.ELEMENT_NODE, node.getNodeType());
            assertEquals("Must select <test:element1/> node", "element1", node.getLocalName());

            // 8. Test expression in the child node context
            node = processor.selectSingleNode(document1.getDocumentElement().getFirstChild(), expr);
            assertNotNull("Must select <test:element1/> node, but got null", node);
            assertEquals("Must select <test:element1/> node", Node.ELEMENT_NODE, node.getNodeType());
            assertEquals("Must select <test:element1/> node", "element1", node.getLocalName());

        } finally {
View Full Code Here

                    String xpath = bindingElm.getAttribute("xpath");
                    if (!xpath.equals("")) {
                        XPathProcessor xpathProcessor = (XPathProcessor)manager.lookup(XPathProcessor.ROLE);
                        try {
                            Node node = xpathProcessor.selectSingleNode(document, xpath);
                            if (node == null)
                                throw new BindingException("XPath expression \"" + xpath + "\" didn't return a result.");
                            if (!(node instanceof Element))
                                throw new BindingException("XPath expression \"" + xpath + "\" did not return an element node.");
                            element = (Element)node;
View Full Code Here

                    String xpath = bindingElm.getAttribute("xpath");
                    if (!xpath.equals("")) {
                        XPathProcessor xpathProcessor = (XPathProcessor)manager.lookup(XPathProcessor.ROLE);
                        try {
                            Node node = xpathProcessor.selectSingleNode(document, xpath);
                            if (node == null)
                                throw new BindingException("XPath expression \"" + xpath + "\" didn't return a result.");
                            if (!(node instanceof Element))
                                throw new BindingException("XPath expression \"" + xpath + "\" did not return an element node.");
                            element = (Element)node;
View Full Code Here

                    String xpath = bindingElm.getAttribute("xpath");
                    if (!xpath.equals("")) {
                        XPathProcessor xpathProcessor = (XPathProcessor)manager.lookup(XPathProcessor.ROLE);
                        try {
                            Node node = xpathProcessor.selectSingleNode(document, xpath);
                            if (node == null)
                                throw new BindingException("XPath expression \"" + xpath + "\" didn't return a result.");
                            if (!(node instanceof Element))
                                throw new BindingException("XPath expression \"" + xpath + "\" did not return an element node.");
                            element = (Element)node;
View Full Code Here

                    String xpath = DomHelper.getAttribute(bindingElm, "xpath", null);
                    if (xpath != null) {
                        XPathProcessor xpathProcessor = (XPathProcessor) manager.lookup(XPathProcessor.ROLE);
                        try {
                            Node node = xpathProcessor.selectSingleNode(document, xpath);
                            if (node == null) {
                                throw new BindingException("XPath expression '" + xpath + "' didn't return a result.",
                                                           DomHelper.getLocationObject(bindingElm));
                            }
                            if (!(node instanceof Element)) {
View Full Code Here

                    String xpath = DomHelper.getAttribute(bindingElm, "xpath", null);
                    if (xpath != null) {
                        XPathProcessor xpathProcessor = (XPathProcessor)manager.lookup(XPathProcessor.ROLE);
                        try {
                            Node node = xpathProcessor.selectSingleNode(document, xpath);
                            if (node == null)
                                throw new BindingException("XPath expression \"" + xpath + "\" didn't return a result.");
                            if (!(node instanceof Element))
                                throw new BindingException("XPath expression \"" + xpath + "\" did not return an element node.");
                            element = (Element)node;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.