Package org.dom4j

Examples of org.dom4j.XPath


     * Create the specified XPath expression with the namespaces added
     * via addNamespace().
     */
    protected XPath createXPath( String xpathString )
    {
        XPath xpath = DocumentHelper.createXPath( xpathString );
        xpath.setNamespaceURIs(namespaces);
       
        return xpath;
    }
View Full Code Here


  public void addColumn(String name, String expression) {
    addColumn(name, expression, XMLTableColumnDefinition.OBJECT_TYPE);
  }

  public void addColumn(String name, String expression, int type) {
    XPath xpath = createColumnXPath(expression);
    addColumn(new XMLTableColumnDefinition(name, xpath, type));
  }
View Full Code Here

    addColumn(new XMLTableColumnDefinition(name, xpath, type));
  }

  public void addColumnWithXPathName(String columnNameXPathExpression,
                                     String expression, int type) {
    XPath columnNameXPath = createColumnXPath(columnNameXPathExpression);
    XPath xpath = createColumnXPath(expression);
    addColumn(new XMLTableColumnDefinition(columnNameXPath, xpath, type));
  }
View Full Code Here

  protected XPath createXPath(String expression) {
    return DocumentHelper.createXPath(expression);
  }

  protected XPath createColumnXPath(String expression) {
    XPath xpath = createXPath(expression);

    // associate my variable context
    xpath.setVariableContext(this);

    return xpath;
  }
View Full Code Here

  public int getColumnCount() {
    return definition.getColumnCount();
  }

  public String getColumnName(int columnIndex) {
    XPath xpath = definition.getColumnNameXPath(columnIndex);

    if (xpath != null) {
      System.out.println("Evaluating column xpath: " + xpath + " value: "
          + xpath.valueOf(source));

      return xpath.valueOf(source);
    }

    return definition.getColumnName(columnIndex);
  }
View Full Code Here

    // get all organization elements. need to set namespace
    rootElement = doc.getRootElement();
    String nsuri = rootElement.getNamespace().getURI();
    nsuris.put( "ns", nsuri);

    XPath meta = rootElement.createXPath("//ns:organization");
    meta.setNamespaceURIs(nsuris);

    XPath metares = rootElement.createXPath("//ns:resources");
    metares.setNamespaceURIs(nsuris);
    Element elResources = (Element) metares.selectSingleNode(rootElement);
    if (elResources == null) throw new AssertException("could not find element resources");
   
    List resourcesList = elResources.elements("resource");
    resources = new HashMap(resourcesList.size());
    for (Iterator iter = resourcesList.iterator(); iter.hasNext();) {
View Full Code Here

      }
     
      nodeId++;
      //set resolved file path directly
      String identifierref = item.attributeValue("identifierref");
      XPath meta = rootElement.createXPath("//ns:resource[@identifier='" + identifierref + "']");
      meta.setNamespaceURIs(nsuris);
      String href = (String) resources.get(identifierref);
      if (href != null) {
        treeNode.setUserObject(href);
        // allow lookup of a treenode given a href so we can quickly adjust the menu if the user clicks on hyperlinks within the text
        hrefToTreeNode.put(href, treeNode);
View Full Code Here

    // get all organization elements. need to set namespace
    rootElement = doc.getRootElement();
    String nsuri = rootElement.getNamespace().getURI();
    nsuris.put( "ns", nsuri);

    XPath meta = rootElement.createXPath("//ns:organization");
    meta.setNamespaceURIs(nsuris);
    Element orgaEl = (Element) meta.selectSingleNode(rootElement); // TODO: accept several organizations?
    if (orgaEl == null) throw new AssertException("could not find element organization");

    XPath metares = rootElement.createXPath("//ns:resources");
    metares.setNamespaceURIs(nsuris);
    Element elResources = (Element) metares.selectSingleNode(rootElement);
    if (elResources == null) throw new AssertException("could not find element resources");
   
    List resourcesList = elResources.elements("resource");
    resources = new HashMap(resourcesList.size());
    for (Iterator iter = resourcesList.iterator(); iter.hasNext();) {
View Full Code Here

      gtn.setAccessible(false);
    } else if (item.getName().equals("item")) {
      gtn.setIconCssClass("o_cp_item");
      //set resolved file path directly
      String identifierref = item.attributeValue("identifierref");
      XPath meta = rootElement.createXPath("//ns:resource[@identifier='" + identifierref + "']");
      meta.setNamespaceURIs(nsuris);
      String href = (String) resources.get(identifierref);
      if (href != null) {
        gtn.setUserObject(href);
        // allow lookup of a treenode given a href so we can quickly adjust the menu if the user clicks on hyperlinks within the text
        hrefToTreeNode.put(href, gtn);
View Full Code Here

   * @param item
   * @return Element
   */
  private Element shuffle(Element item) {
    // get the render_choice
    XPath choice = DocumentHelper.createXPath(".//render_choice[@shuffle=\"Yes\"]");
    Element tel_rendchoice = (Element) choice.selectSingleNode(item);
    //if shuffle is disable, just return the item
    if (tel_rendchoice == null) return item;
    // else: we have to shuffle
    // assume: all response_label have same parent: either render_choice or a
    // flow_label
    Element shuffleItem = item.createCopy();
    // clone the whole item
    Element el_rendchoice = (Element) choice.selectSingleNode(shuffleItem);
    //  <!ELEMENT render_choice ((material | material_ref | response_label |
    // flow_label)* ,response_na?)>
    // <!ATTLIST response_label rshuffle (Yes | No ) 'Yes' .....
    List el_labels = el_rendchoice.selectNodes(".//response_label[@rshuffle=\"Yes\"]");
    int shusize = el_labels.size();
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.