Package org.dom4j

Examples of org.dom4j.XPath.selectSingleNode()


      Element item = (Element) iter.next();
      String identifierref = item.attributeValue("identifierref");
      if (identifierref == null) continue;
      XPath resourceXPath = rootElement.createXPath("//ns:resource[@identifier='" + identifierref + "']");
      resourceXPath.setNamespaceURIs(nsuris);
      Element elResource = (Element)resourceXPath.selectSingleNode(elResources);
      if (elResource == null) throw new AddingResourceException("resource.no.matching.resource");
      if (elResource.attribute("scormtype") != null) return false;
      if (elResource.attribute("scormType") != null) return false;
      if (elResource.attribute("SCORMTYPE") != null) return false;
      if (elResource.attributeValue("href") != null) return true; // success.
View Full Code Here


        XPath xpath = DocumentHelper.createXPath("/xhtml:html/xhtml:body/xhtml:p");
        Map<String, String> namespaceUris = new HashMap<String, String>();
        namespaceUris.put("xhtml", "http://www.w3.org/1999/xhtml");
        xpath.setNamespaceURIs(namespaceUris);
       
        Node paragraphNode = xpath.selectSingleNode(doc);
        Assert.assertNotNull(paragraphNode);
        Assert.assertEquals("this is a test", paragraphNode.getText());
    }
   
   
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

    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

  private int[] extractBoxConstraint(Element root) {
    int[] result = new int[4];
    String nodeName = currentToken.getNode().getName();
    XPath xPath = new DefaultXPath("//node[@name='" + nodeName + "']");
    Element node = (Element) xPath.selectSingleNode(root);
    result[0] = Integer.valueOf(node.attribute("x").getValue()).intValue();
    result[1] = Integer.valueOf(node.attribute("y").getValue()).intValue();
    result[2] = Integer.valueOf(node.attribute("width").getValue()).intValue();
    result[3] = Integer.valueOf(node.attribute("height").getValue()).intValue();
    return result;
View Full Code Here

  private int[] extractBoxConstraint(Element root, Token token) {
      int[] result = new int[4];
      String nodeName = token.getNode().getName();
      XPath xPath = new DefaultXPath("//node[@name='" + nodeName + "']");
      Element node = (Element) xPath.selectSingleNode(root);
      result[0] = Integer.valueOf(node.attribute("x").getValue()).intValue();
      result[1] = Integer.valueOf(node.attribute("y").getValue()).intValue();
      result[2] = Integer.valueOf(node.attribute("width").getValue()).intValue();
      result[3] = Integer.valueOf(node.attribute("height").getValue()).intValue();
      return result;
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
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.