Package org.dom4j

Examples of org.dom4j.XPath


        }
    }

    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

    }

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

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

    }

    public List getElementList( String xpathExpr )
        throws XMLException
    {
        XPath xpath = createXPath( xpathExpr );
        Object evaluated = xpath.evaluate( document );

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

    SAXReader xmlReader =  getSAXReader();

    Document document = xmlReader.read(outputXml);

    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set/key");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one key element", 1, list.size());
    Element node = (Element) list.get(0);
    if (node.attribute( "column" ) != null){//implied attribute
      assertEquals(node.attribute( "column" ).getText(),"searchString");
    } else {
View Full Code Here

    SAXReader xmlReader =  getSAXReader();

    Document document = xmlReader.read(outputXml);

    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one set element", 1, list.size());
    Element node = (Element) list.get(0);
    assertEquals(node.attribute( "name" ).getText(),"searchResults");
    assertEquals(node.attribute( "access" ).getText(),"field");

    xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set/element");
    list = xpath.selectNodes(document);
    assertEquals("Expected to get one element 'element'", 1, list.size());
    node = (Element) list.get(0);
    assertEquals(node.attribute( "type" ).getText(), "string");
    list = node.selectNodes("column");
    assertEquals("Expected to get one element 'column'", 1, list.size());
View Full Code Here

    SAXReader xmlReader =  getSAXReader();

    Document document = xmlReader.read(outputXml);

    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/any");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one any element", 1, list.size());
    Element node = (Element) list.get(0);
    assertEquals(node.attribute( "name" ).getText(),"someSpecificProperty");
    assertEquals(node.attribute( "id-type" ).getText(),"long");
    assertEquals(node.attribute( "meta-type" ).getText(),"string");
View Full Code Here

    SAXReader xmlReader =  getSAXReader();

    Document document = xmlReader.read(outputXml);

    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/map");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one any element", 1, list.size());
    Element node = (Element) list.get(0);
    assertEquals(node.attribute( "name" ).getText(),"generalProperties");
    assertEquals(node.attribute( "table" ).getText(),"T_GEN_PROPS");
    assertEquals(node.attribute( "lazy" ).getText(),"true");
View Full Code Here

    SAXReader xmlReader =  this.getSAXReader();
   
    Document document = xmlReader.read(outputXml);   
 
    XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/comment");
    List list = xpath.selectNodes(document);
    assertEquals("Expected to get one comment element", 1, list.size());
    Node node = (Node) list.get(0);
    assertEquals(node.getText(),"A comment for ClassFullAttribute");
   
    xpath = DocumentHelper.createXPath("//hibernate-mapping/class/property/column/comment");
    list = xpath.selectNodes(document);
    assertEquals("Expected to get one comment element", 1, list.size());
    node = (Node) list.get(0);
    assertEquals(node.getText(),"columnd comment");
  }
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.