Package org.dom4j

Examples of org.dom4j.XPath.selectSingleNode()


    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


    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);
View Full Code Here

    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

   * @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
View Full Code Here

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

    // 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");
View Full Code Here

    // 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.
View Full Code Here

      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

    // 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>, which will serve as an entry point.
    // This is mandatory, as we need an entry point as the user has the option of setting
    // CPDisplayController to not display a menu at all, in which case the first <item>/<resource>
View Full Code Here

    // This is mandatory, as we need an entry point as the user has the option of setting
    // CPDisplayController to not display a menu at all, in which case the first <item>/<resource>
    // element pair gets displayed.
    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("resource.no.item"); // no <item> element.
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.