Package org.apache.commons.jxpath

Examples of org.apache.commons.jxpath.JXPathContext.selectNodes()


        trans.transform(source, result);
        Node root = ((Document) result.getNode()).getDocumentElement();
        JXPathContext ctx = JXPathContext.newContext(root);

        assertEquals("Wrong root name", rootName, root.getNodeName());
        assertEquals("Wrong number of children", 3, ctx.selectNodes("/*").size());

        check(ctx, "world/continents/continent", CONTINENTS);
        check(ctx, "world/greeting", new String[] { "Hello", "Salute" });
        check(ctx, "world/wish", "Peace");
        check(ctx, "application/mail/smtp", "smtp.mymail.org");
View Full Code Here


     * @return the mock context
     */
    private JXPathContext expectSelect(Object... results)
    {
        JXPathContext ctx = EasyMock.createMock(JXPathContext.class);
        EasyMock.expect(ctx.selectNodes(TEST_KEY)).andReturn(
                Arrays.asList(results));
        EasyMock.replay(ctx);
        return ctx;
    }

View Full Code Here

        // extracting all form variables
        List<String> rootGroupElementNames = new ArrayList<String>();

        Node rootNode = (Node) xsdDocContext.selectSingleNode("/xsd:schema/xsd:element[@name=\"" + rootGroup + "\"]");
        JXPathContext rootGroupContext = JXPathContext.newContext(xsdDocContext, rootNode);
        List<Node> nodes = rootGroupContext.selectNodes("//xsd:element");
        for (Node node : nodes) {
            JXPathContext elementContext = JXPathContext.newContext(xsdDocContext, node);
            String globalName = (String) elementContext.getValue("@ref");
            rootGroupElementNames.add(globalName.substring(namespace.length() + 1));
        }
View Full Code Here

            if (object instanceof NativeJavaObject) {
                object = ((NativeJavaObject) object).unwrap();
            }
            JXPathContext jxContext = JXPathContext.newContext(object);
            jxContext.setLenient(true);
            results = jxContext.selectNodes(xpath);
        }
        return convertXMLObjects(results, true);
    }
   
    public static Document load(String url) throws UnsupportedEncodingException, WGAPIException, IOException, HttpException, SAXException, DocumentException {
View Full Code Here

            return result;
        }
        else
        {
            JXPathContext context = createContext(root, key);
            List result = context.selectNodes(key);
            return (result != null) ? result : Collections.EMPTY_LIST;
        }
    }

    /**
 
View Full Code Here

            return Collections.singletonList(result);
        }
        else
        {
            JXPathContext context = createContext(root, handler);
            List<?> results = context.selectNodes(key);
            if (results == null)
            {
                results = Collections.emptyList();
            }
            return convertResults(results);
View Full Code Here

    @SuppressWarnings("unchecked")
    static Iterable<CssRule> parseCssRules(final Reader reader) throws RecognitionException, IOException {
        List<CssRule> cssRuleList = new ArrayList<CssRule>();
        Document root = parseCssToDocument(reader);
        JXPathContext context = JXPathContext.newContext(root.getRootElement());
        List<Element> cssRuleElementList = (List<Element>) context.selectNodes("/RULE");
        for (Element element : cssRuleElementList) {
            final CssRuleJdom cssRuleJdom = new CssRuleJdom(element, 0);
            cssRuleList.add(cssRuleJdom);
            for (int i = 1; i < cssRuleJdom.getNumberOfCommaSeparatedSelectorLists(); i++) {
                cssRuleList.add(new CssRuleJdom(element, i));
View Full Code Here

    @SuppressWarnings("unchecked")
    private void parseDeclarations() {
        cssDeclarationList = new ArrayList<CssDeclaration>();
        JXPathContext context = JXPathContext.newContext(ruleElement);
        List<Element> cssSelectorElementList = (List<Element>) context.selectNodes("/" + CssTokenType.PROPERTY.name());

        for (Element element : cssSelectorElementList) {
            cssDeclarationList.add(new CssDeclarationJdom(this, element));
        }
    }
View Full Code Here

    }

    private List<ImportDeclaration> parseImportDeclaration() {
        try {
            final JXPathContext context = JXPathContext.newContext(root);
            final List importNodes = context.selectNodes("/" + JAVA_SOURCE_ROOT_ELEMENT_NAME + "/" +
                                                                 JavaSourceTokenType.IMPORT.name());
            importDeclarations = new ArrayList<ImportDeclaration>(importNodes.size());
            for (Object importNode : importNodes) {
                importDeclarations.add(new ImportDeclarationJdom((Element) importNode));
            }
View Full Code Here

    //////////////////////////////////////////////////////////////////////////////////////////////////

    public static List<Annotation> parseAnnotations(final Element element) {
        final List<Annotation> annotations;
        JXPathContext context = JXPathContext.newContext(element);
        List annotationList = context.selectNodes("/" + JavaSourceTokenType.MODIFIER_LIST.getName() +
                                                          "/" + JavaSourceTokenType.AT.getName());
        annotations = new ArrayList<Annotation>(annotationList.size());
        for (Object annotationElement : annotationList) {
            annotations.add(new AnnotationJdom((Element) annotationElement));
        }
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.