Package org.dom4j

Examples of org.dom4j.Element.attributeValue()


    for (Iterator iter = sections.iterator(); iter.hasNext();) {
      Element el_section = (Element) iter.next();

      // resolve sectionref into the correct sections
      if (el_section.getName().equals("sectionref")) {
        String linkRefId = el_section.attributeValue("linkrefid");
        el_section = (Element) el_section.selectSingleNode("//section[@ident='" + linkRefId + "']");
        if (el_section == null) { throw new RuntimeException("sectionref with ref '" + linkRefId + "' could not be resolved"); }
      }

      SectionContext sc = new SectionContext();
View Full Code Here


        float totalscore = getScore();
        boolean fulfilled = sbe.eval(el_varandornot, totalscore);
        if (fulfilled) {
          // get feedback
          Element el_displayfeedback = (Element) el_oft.selectSingleNode("displayfeedback");
          String linkRefId = el_displayfeedback.attributeValue("linkrefid");
          // must exist (dtd)
          // ignore feedbacktype, since we section or assess feedback only
          // accepts material, no hints or solutions
          Element el_resolved = (Element) el_assessment.selectSingleNode(".//assessfeedback[@ident='" + linkRefId + "']");
          getOutput().setEl_response(new AssessFeedback(el_resolved));
View Full Code Here

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

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

      if (scormAttr == null && scormAttrUpper == null) throw new AddingResourceException("scorm.no.attribute.scormtype");
      String attr = "";
      if (scormAttr != null) attr = scormAttr.getStringValue();
      if (scormAttrUpper != null) attr = scormAttrUpper.getStringValue();
      if (attr == null) throw new AddingResourceException("scorm.no.attribute.value");
      if (elResource.attributeValue("href") != null && (attr.equalsIgnoreCase("sco") || attr.equalsIgnoreCase("asset"))) return true; // success.
    }
    throw new AddingResourceException("resource.general.error");
  }
}
View Full Code Here

      ///todo
      float fPoints = 0;
      try {
        Element el_setvar = el_resp_condition.element("setvar");
        if (el_setvar == null) continue;
        if (!el_setvar.attributeValue("action").equals("Add") && !el_setvar.attributeValue("action").equals("Subtract")
            && !el_setvar.attributeValue("action").equals("Set")) continue;
        fPoints = new Float(el_setvar.getTextTrim()).floatValue();
        if (el_setvar.attributeValue("action").equals("Subtract")) fPoints = fPoints * -1;
      } catch (NumberFormatException nfe) {
        continue;
View Full Code Here

      ///todo
      float fPoints = 0;
      try {
        Element el_setvar = el_resp_condition.element("setvar");
        if (el_setvar == null) continue;
        if (!el_setvar.attributeValue("action").equals("Add") && !el_setvar.attributeValue("action").equals("Subtract")
            && !el_setvar.attributeValue("action").equals("Set")) continue;
        fPoints = new Float(el_setvar.getTextTrim()).floatValue();
        if (el_setvar.attributeValue("action").equals("Subtract")) fPoints = fPoints * -1;
      } catch (NumberFormatException nfe) {
        continue;
View Full Code Here

      float fPoints = 0;
      try {
        Element el_setvar = el_resp_condition.element("setvar");
        if (el_setvar == null) continue;
        if (!el_setvar.attributeValue("action").equals("Add") && !el_setvar.attributeValue("action").equals("Subtract")
            && !el_setvar.attributeValue("action").equals("Set")) continue;
        fPoints = new Float(el_setvar.getTextTrim()).floatValue();
        if (el_setvar.attributeValue("action").equals("Subtract")) fPoints = fPoints * -1;
      } catch (NumberFormatException nfe) {
        continue;
      }
View Full Code Here

        Element el_setvar = el_resp_condition.element("setvar");
        if (el_setvar == null) continue;
        if (!el_setvar.attributeValue("action").equals("Add") && !el_setvar.attributeValue("action").equals("Subtract")
            && !el_setvar.attributeValue("action").equals("Set")) continue;
        fPoints = new Float(el_setvar.getTextTrim()).floatValue();
        if (el_setvar.attributeValue("action").equals("Subtract")) fPoints = fPoints * -1;
      } catch (NumberFormatException nfe) {
        continue;
      }
      if (fPoints != 0) {
        Element conditionvar = el_resp_condition.element("conditionvar");
View Full Code Here

        List tmp_points = (and == null) ? conditionvar.selectNodes(".//varequal") : and.selectNodes(".//varequal");
        for (Iterator iter = tmp_points.iterator(); iter.hasNext();) {
          Element el_varequal = (Element) iter.next();
          if (type == Question.TYPE_SC || type == Question.TYPE_MC || type == Question.TYPE_KPRIM) points.put(el_varequal.getTextTrim(), new Float(fPoints));
          else if (type == Question.TYPE_FIB) points.put(el_varequal.attributeValue("respident"), new Float(fPoints));
        }
      }
    }
    return points;
  }
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.