Examples of SAXElement


Examples of org.milyn.delivery.sax.SAXElement

    public void test_2_1() throws SAXPathException {
        SelectorStep[] steps = SelectorStepBuilder.buildSteps("x/y[@d = 23]/*", namespaces);
        assertEquals("x/y(@d = 23.0)/*", SelectorStepBuilder.toString(steps));

        SAXElement y = new SAXElement(null, "y");

        assertFalse(steps[1].getPredicatesEvaluator().evaluate(y, null));

        y.setAttribute("d", "22");
        assertFalse(steps[1].getPredicatesEvaluator().evaluate(y, null));

        y.setAttribute("d", "23");
        assertTrue(steps[1].getPredicatesEvaluator().evaluate(y, null));
    }
View Full Code Here

Examples of org.milyn.delivery.sax.SAXElement

        assertEquals("x/y(((@d = 23.0) or (text() = 'ddd')) and (@h = 'rrr'))", SelectorStepBuilder.toString(steps));

        assertFalse(steps[0].accessesText());
        assertTrue(steps[1].accessesText());

        SAXElement y = new SAXElement(null, "y");
        y.setAttribute("d", "2");
        y.addText("dd");
        y.setAttribute("h", "rr");
        assertFalse(steps[1].getPredicatesEvaluator().evaluate(y, null));

        y = new SAXElement(null, "y");
        y.setAttribute("d", "23");
        y.addText("dd");
        y.setAttribute("h", "rr");
        assertFalse(steps[1].getPredicatesEvaluator().evaluate(y, null));

        y = new SAXElement(null, "y");
        y.setAttribute("d", "23");
        y.addText("dd");
        y.setAttribute("h", "rrr");
        assertTrue(steps[1].getPredicatesEvaluator().evaluate(y, null));

        y = new SAXElement(null, "y");
        y.setAttribute("d", "2");
        y.addText("dd");
        y.setAttribute("h", "rrr");
        assertFalse(steps[1].getPredicatesEvaluator().evaluate(y, null));

        y = new SAXElement(null, "y");
        y.setAttribute("d", "2");
        y.addText("ddd");
        y.setAttribute("h", "rrr");
        assertTrue(steps[1].getPredicatesEvaluator().evaluate(y, null));
    }
View Full Code Here

Examples of org.milyn.delivery.sax.SAXElement

    public void test_3_2() throws SAXPathException {
        SelectorStep[] steps = SelectorStepBuilder.buildSteps("y[@d = 23 and text() = 35]", namespaces);
        assertEquals("y((@d = 23.0) and (text() = 35.0))", SelectorStepBuilder.toString(steps));

        SAXElement y = new SAXElement(null, "y");
        y.setAttribute("d", "2");
        assertFalse(steps[0].getPredicatesEvaluator().evaluate(y, null));

        y = new SAXElement(null, "y");
        y.setAttribute("d", "23");
        y.addText("dd");
        assertFalse(steps[0].getPredicatesEvaluator().evaluate(y, null));

        y = new SAXElement(null, "y");
        y.setAttribute("d", "23");
        y.addText("35");
        assertTrue(steps[0].getPredicatesEvaluator().evaluate(y, null));
    }
View Full Code Here

Examples of org.milyn.delivery.sax.SAXElement

    public void test_3_3() throws SAXPathException {
        SelectorStep[] steps = SelectorStepBuilder.buildSteps("y[@a:d = 23]", namespaces);
        assertEquals("y(@{http://a}d = 23.0)", SelectorStepBuilder.toString(steps));

        SAXElement y = new SAXElement(null, "y");
        y.setAttribute("d", "23");
        assertFalse(steps[0].getPredicatesEvaluator().evaluate(y, null));

        y = new SAXElement(null, "y");
        y.setAttributeNS("http://a", "d", "23");
        assertTrue(steps[0].getPredicatesEvaluator().evaluate(y, null));
    }
View Full Code Here

Examples of org.milyn.delivery.sax.SAXElement

    public void test_3_4() throws SAXPathException {
        SelectorStep[] steps = SelectorStepBuilder.buildSteps("y[@a:d < 23]", namespaces);
        assertEquals("y(@{http://a}d < 23.0)", SelectorStepBuilder.toString(steps));

        SAXElement y = new SAXElement(null, "y");
        y.setAttribute("d", "23");
        assertFalse(steps[0].getPredicatesEvaluator().evaluate(y, null));

        y = new SAXElement(null, "y");
        y.setAttributeNS("http://a", "d", "22");
        assertTrue(steps[0].getPredicatesEvaluator().evaluate(y, null));

        y = new SAXElement(null, "y");
        y.setAttributeNS("http://a", "d", "23");
        assertFalse(steps[0].getPredicatesEvaluator().evaluate(y, null));
    }
View Full Code Here

Examples of org.milyn.delivery.sax.SAXElement

    public void test_3_5() throws SAXPathException {
        SelectorStep[] steps = SelectorStepBuilder.buildSteps("y[@a:d > 23]", namespaces);
        assertEquals("y(@{http://a}d > 23.0)", SelectorStepBuilder.toString(steps));

        SAXElement y = new SAXElement(null, "y");
        y.setAttribute("d", "23");
        assertFalse(steps[0].getPredicatesEvaluator().evaluate(y, null));

        y = new SAXElement(null, "y");
        y.setAttributeNS("http://a", "d", "24");
        assertTrue(steps[0].getPredicatesEvaluator().evaluate(y, null));

        y = new SAXElement(null, "y");
        y.setAttributeNS("http://a", "d", "23");
        assertFalse(steps[0].getPredicatesEvaluator().evaluate(y, null));
    }
View Full Code Here

Examples of org.milyn.delivery.sax.SAXElement

        return this;
    }

    @Override
    protected void writeStart(SAXElement element) throws IOException {
        SAXElement reconstructedElement = reconstructElement(element);
        super.writeStart(reconstructedElement);
        element.setCache(this, reconstructedElement.getCache(this));
    }
View Full Code Here

Examples of org.milyn.delivery.sax.SAXElement

        element.setCache(this, reconstructedElement.getCache(this));
    }

    @Override
    protected void writeEnd(SAXElement element) throws IOException {
        SAXElement reconstructedElement = reconstructElement(element);
        reconstructedElement.setCache(this, element.getCache(this));
        super.writeEnd(reconstructedElement);
    }
View Full Code Here

Examples of org.milyn.delivery.sax.SAXElement

            String newElementNamespacePrefix = (elementNamespacePrefix != null? elementNamespacePrefix : qName.getPrefix());

            qName = new QName(newElementNamespace, newElementName, newElementNamespacePrefix);
        }

        SAXElement newElement = new SAXElement(qName, element.getAttributes(), element.getParent());
        newElement.setWriter(element.getWriter(this), this);

        if(!attributes.isEmpty()) {
            Map<String, Object> beans = Filter.getCurrentExecutionContext().getBeanContext().getBeanMap();
            Set<Map.Entry<QName, FreeMarkerTemplate>> attributeSet = attributes.entrySet();

            for(Map.Entry<QName, FreeMarkerTemplate> attributeConfig : attributeSet) {
                QName attribName = attributeConfig.getKey();
                FreeMarkerTemplate valueTemplate = attributeConfig.getValue();
                String namespaceURI = attribName.getNamespaceURI();

                if(namespaceURI != null) {
                    String prefix = attribName.getPrefix();
                    if(prefix != null && prefix.length() > 0) {
                        newElement.setAttributeNS(namespaceURI, prefix + ":" + attribName.getLocalPart(), valueTemplate.apply(beans));
                    } else {
                        newElement.setAttributeNS(namespaceURI, attribName.getLocalPart(), valueTemplate.apply(beans));
                    }
                } else {
                    newElement.setAttribute(attribName.getLocalPart(), valueTemplate.apply(beans));
                }
            }
        }

        return newElement;
View Full Code Here

Examples of org.milyn.delivery.sax.SAXElement

                    return true;
                }
                parent = parent.getParentNode();
            }
        } else if(fragment.isSAXElement() && isSAXElement()) {
            SAXElement parent = fragment.saxFragment.getParent();
            while(parent != null) {
                if(parent == saxFragment) {
                    return true;
                }
                parent = parent.getParent();
            }
        }

        return false;
    }
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.