Examples of XPath


Examples of org.dom4j.XPath

  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

Examples of org.dom4j.XPath

    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

Examples of org.dom4j.XPath

  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

Examples of org.dom4j.XPath

  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

Examples of org.dom4j.XPath

    // 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

Examples of org.dom4j.XPath

      }
     
      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

Examples of org.dom4j.XPath

    // 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

Examples of org.dom4j.XPath

      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

Examples of org.dom4j.XPath

   * @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

Examples of org.dom4j.XPath

    if (simpleSeqencingUri != null) nsuris.put("imsss", simpleSeqencingUri);

    // Check for organiztaion element. Must provide at least one... title gets ectracted from either
    // the (optional) <title> element or the mandatory identifier attribute.
    // This makes sure, at least a root node gets created in CPManifestTreeModel. 
    XPath meta = rootElement.createXPath("//ns:organization");
    meta.setNamespaceURIs(nsuris);
    Element orgaEl = (Element) meta.selectSingleNode(rootElement); // TODO: accept several organizations?
    if (orgaEl == null) throw new AddingResourceException("resource.no.organisation");

    // Check for at least one <item> element referencing a <resource> of adlcp:scormtype="sco" or "asset",
    // which will serve as an entry point.
    XPath resourcesXPath = rootElement.createXPath("//ns:resources");
    resourcesXPath.setNamespaceURIs(nsuris);
    Element elResources = (Element)resourcesXPath.selectSingleNode(rootElement);
    if (elResources == null) throw new AddingResourceException("resource.no.resource"); // no <resources> element.
    XPath itemsXPath = rootElement.createXPath("//ns:item");
    itemsXPath.setNamespaceURIs(nsuris);
    List items = itemsXPath.selectNodes(rootElement);
    if (items.size() == 0) throw new AddingResourceException("scorm.no.item"); // no <item> element.
   
    // check for scorm 2004 simple sequencing stuff which we do not yet support
    if (seqencingUri != null) {
        XPath seqencingXPath = rootElement.createXPath("//ns:imsss");
        List sequences = seqencingXPath.selectNodes(rootElement);
        if (sequences.size() > 0) throw new AddingResourceException("scorm.found.seqencing"); // seqencing elements found -> scorm 2004
    }
   
    Set set = new HashSet();
    for (Iterator iter = items.iterator(); iter.hasNext();) {
      Element item = (Element) iter.next();
      String identifier = item.attributeValue("identifier");
      //check if identifiers are unique, reject if not so
      if (!set.add(identifier)) throw new AddingResourceException("resource.general.error");//TODO:create special error message for non unique ids
    }
   
   
    for (Iterator iter = items.iterator(); iter.hasNext();) {
      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");
      //check for scorm attribute
      Attribute scormAttr = elResource.attribute("scormtype");
      //some packages have attribute written like "scormType"
      Attribute scormAttrUpper = elResource.attribute("scormType");
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.