Package org.polyglotted.xpathstax.api

Examples of org.polyglotted.xpathstax.api.AttributeProvider


    @Test
    public void testCanProcessWithAttribute() {
        String expected = "/response/documents";
        XmlAttribute attribute = XmlAttribute.from("numberFound=12345");
        AttributeProvider provider = testProvider(expected, attribute);
        String childElem = "/response/documents/document";
        AttributeProvider failProvider = testProvider(expected, EMPTY);

        XPathRequest req = new XPathRequest("/response/documents[@numberFound]/*");

        assertTrue(req.canProcess(expected, attribute, failProvider));
        assertTrue(req.canProcess(expected, EMPTY, provider));
View Full Code Here


    @Test
    public void testCanProcessWithAttributeValue() {
        String expected = "/response/documents/document/fields/field/value";
        String childElem = "/response/documents/document/fields/field/value/string";
        AttributeProvider provider = testProvider("/response/documents/document/fields/field",
                        XmlAttribute.from("name='.id'"));
        AttributeProvider failProvider = testProvider("/response/documents/document/fields",
                        XmlAttribute.from("name='.id'"));

        XPathRequest req = new XPathRequest("/response/documents/document/fields/field[@name='.id']/value");

        assertTrue(req.canProcess(expected, EMPTY, provider));
View Full Code Here

        assertFalse(req.canProcess(expected, EMPTY, failProvider));
        assertFalse(req.canProcess(childElem, EMPTY, provider));
    }

    private AttributeProvider testProvider(final String elem, final XmlAttribute attribute) {
        return new AttributeProvider() {
            @Override
            public XmlAttribute getAttribute(String attribElem) {
                if (elem.equals(attribElem)) {
                    return attribute;
                }
View Full Code Here

TOP

Related Classes of org.polyglotted.xpathstax.api.AttributeProvider

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.