Package org.dom4j

Examples of org.dom4j.XPath


            {
                throw new IllegalArgumentException(CoreMessages.objectNotOfCorrectType(
                        src.getClass(), new Class[]{org.w3c.dom.Document.class, Document.class, String.class, byte[].class}).getMessage());
            }

            XPath xpath = dom4jDoc.createXPath(splitExpression);
            if (namespaces != null)
            {
                xpath.setNamespaceURIs(namespaces);
            }

            List foundNodes = xpath.selectNodes(dom4jDoc);
            if (enableCorrelation != CorrelationMode.NEVER)
            {
                message.setCorrelationGroupSize(foundNodes.size());
            }
            if (logger.isDebugEnabled())
View Full Code Here


            Object result = null;
            if (src instanceof String)
            {
                Document doc = DocumentHelper.parseText((String) src);

                XPath xpath = doc.createXPath(expression);
                if (namespaces != null)
                {
                    xpath.setNamespaceURIs(namespaces);
                }
               
                // This is the way we always did it before, so keep doing it that way
                // as xpath.evaluate() will return non-string results (like Doubles)
                // for some scenarios.
                if (outputType == null && singleResult)
                {
                    return xpath.valueOf(doc);
                }
               
                // TODO handle non-list cases, see
                //http://www.dom4j.org/apidocs/org/dom4j/XPath.html#evaluate(java.lang.Object)
                Object obj = xpath.evaluate(doc);
                if (obj instanceof List)
                {
                    for (int i = 0; i < ((List) obj).size(); i++)
                    {
                        final Node node = (Node) ((List) obj).get(i);
View Full Code Here

        if ( doc == null )
        {
            throw new AssertionFailedError( "Unable to assert an attribute using a null document." );
        }
   
        XPath xpath = doc.createXPath( xpathToNode );
   
        Node node = xpath.selectSingleNode( doc );
   
        if ( node != null )
        {
            throw new AssertionFailedError( "Element at '" + xpathToNode + "' should not exist." );
        }
View Full Code Here

        if ( doc == null )
        {
            throw new AssertionFailedError( "Unable to assert an attribute using a null document." );
        }
   
        XPath xpath = doc.createXPath( xpathToNode );
   
        Node node = xpath.selectSingleNode( doc );
   
        if ( node == null )
        {
            throw new AssertionFailedError( "Expected Node at '" + xpathToNode + "', but was not found." );
        }
View Full Code Here

        if ( doc == null )
        {
            throw new AssertionFailedError( "Unable to assert an attribute using a null document." );
        }
   
        XPath xpath = doc.createXPath( xpathToParentNode );
   
        List nodes = xpath.selectNodes( doc );
   
        if ( ( nodes == null ) || nodes.isEmpty() )
        {
            throw new AssertionFailedError( "Expected Node(s) at '" + xpathToParentNode + "', but was not found." );
        }
View Full Code Here

          Iterator propertyAlias = rootElement.elementIterator("propertyAlias");
            while (propertyAlias.hasNext()) {
                Element e = (Element) propertyAlias.next();
                String propertyName = e.valueOf("@propertyName");

                XPath xpathSelector = DocumentHelper.createXPath("//*/defaultNS:property[@name=\"" + propertyName + "\"]");
                HashMap nsMap = new HashMap(1);
                nsMap.put("defaultNS", BPEL_NS);
                xpathSelector.setNamespaceURIs(nsMap);
                Node propNode = xpathSelector.selectSingleNode(doc);

                Property prop = (Property) addedProperty.get(propertyName);
                if (propNode != null && prop == null) {
                    prop = ProcessFactory.addProperty(tp,
                            propertyName, propNode.valueOf("@type"));
View Full Code Here

    }

    public Element getElement( String xpathExpr )
        throws XMLException
    {
        XPath xpath = createXPath( xpathExpr );
        Object evaluated = xpath.selectSingleNode( document );

        if ( evaluated == null )
        {
            return null;
        }
View Full Code Here

        }
    }

    private XPath createXPath( String xpathExpr )
    {
        XPath xpath = document.createXPath( xpathExpr );
        if ( !this.namespaceMap.isEmpty() )
        {
            xpath.setNamespaceURIs( this.namespaceMap );
        }
        return xpath;
    }
View Full Code Here

    }

    public boolean hasElement( String xpathExpr )
        throws XMLException
    {
        XPath xpath = createXPath( xpathExpr );
        Object evaluated = xpath.selectSingleNode( document );

        if ( evaluated == null )
        {
            return false;
        }
View Full Code Here

    }

    public String getElementText( Node context, String xpathExpr )
        throws XMLException
    {
        XPath xpath = createXPath( xpathExpr );
        Object evaluated = xpath.selectSingleNode( context );

        if ( evaluated == null )
        {
            return null;
        }
View Full Code Here

TOP

Related Classes of org.dom4j.XPath

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.