当前位置: 首页>>代码示例>>Java>>正文


Java Element.getAttributeValue方法代码示例

本文整理汇总了Java中org.kxml2.kdom.Element.getAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getAttributeValue方法的具体用法?Java Element.getAttributeValue怎么用?Java Element.getAttributeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kxml2.kdom.Element的用法示例。


在下文中一共展示了Element.getAttributeValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseBind

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
protected void parseBind(Element e) {
  // remember raw bindings in case we want to compare parsed XForms later
  parser.bindElements.add(copyBindingElement(e));
  List<String> usedAtts = new ArrayList<String>();

  DataBinding binding = processStandardBindAttributes(usedAtts, e);

  String value = e.getAttributeValue(ParserConsts.NAMESPACE_ODK, "length");
  if (value != null) {
    e.setAttribute(ParserConsts.NAMESPACE_ODK, "length", null);
  }

  log.info("Calling handle found value " + ((value == null) ? "null" : value));

  if (value != null) {
    Integer iValue = Integer.valueOf(value);
    parser.setNodesetStringLength(e.getAttributeValue(null, "nodeset"), iValue);
  }

  // print unused attribute warning message for parent element
  if (XFormUtils.showUnusedAttributeWarning(e, usedAtts)) {
    System.out.println(XFormUtils.unusedAttWarning(e, usedAtts));
  }

  addBinding(binding);
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:27,代码来源:BaseFormParserForJavaRosa.java

示例2: parseMeta

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private void parseMeta (Element e) {
     List<String> usedAtts = new ArrayList<String>();
	int attributes = e.getAttributeCount();
	for(int i = 0 ; i < attributes ; ++i) {
		String name = e.getAttributeName(i);
		String value = e.getAttributeValue(i);
		if("name".equals(name)) {
			_f.setName(value);
		}
	}


	usedAtts.add("name");
	if(XFormUtils.showUnusedAttributeWarning(e, usedAtts)){
		reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:18,代码来源:XFormParser.java

示例3: parseUpload

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
protected QuestionDef parseUpload(IFormElement parent, Element e, int controlUpload) {
    List<String> usedAtts = new ArrayList<String>();
usedAtts.add("mediatype");
// get media type value
String mediaType = e.getAttributeValue(null, "mediatype");
// parse the control
QuestionDef question = parseControl(parent, e, controlUpload, usedAtts);

// apply the media type value to the returned question def.
if ("image/*".equals(mediaType)) {
	// NOTE: this could be further expanded.
	question.setControlType(Constants.CONTROL_IMAGE_CHOOSE);
} else if("audio/*".equals(mediaType)) {
          question.setControlType(Constants.CONTROL_AUDIO_CAPTURE);
      } else if ("video/*".equals(mediaType)) {
          question.setControlType(Constants.CONTROL_VIDEO_CAPTURE);
      }
      return question;
  }
 
开发者ID:medic,项目名称:javarosa,代码行数:20,代码来源:XFormParser.java

示例4: parseQuestionLabel

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private void parseQuestionLabel (QuestionDef q, Element e) {
	String label = getLabel(e);
	String ref = e.getAttributeValue("", REF_ATTR);

     List<String> usedAtts = new ArrayList<String>();
	usedAtts.add(REF_ATTR);

	if (ref != null) {
		if (ref.startsWith(ITEXT_OPEN) && ref.endsWith(ITEXT_CLOSE)) {
			String textRef = ref.substring(ITEXT_OPEN.length(), ref.indexOf(ITEXT_CLOSE));

			verifyTextMappings(textRef, "Question <label>", true);
			q.setTextID(textRef);
		} else {
			throw new RuntimeException("malformed ref [" + ref + "] for <label>");
		}
	} else {
		q.setLabelInnerText(label);
	}


	if(XFormUtils.showUnusedAttributeWarning(e, usedAtts)){
		reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:26,代码来源:XFormParser.java

示例5: parseHint

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private void parseHint (QuestionDef q, Element e) {
     List<String> usedAtts = new ArrayList<String>();
	usedAtts.add(REF_ATTR);
	String hint = getXMLText(e, true);
	String hintInnerText = getLabel(e);
	String ref = e.getAttributeValue("", REF_ATTR);

	if (ref != null) {
		if (ref.startsWith(ITEXT_OPEN) && ref.endsWith(ITEXT_CLOSE)) {
			String textRef = ref.substring(ITEXT_OPEN.length(), ref.indexOf(ITEXT_CLOSE));

			verifyTextMappings(textRef, "<hint>", false);
			q.setHelpTextID(textRef);
		} else {
			throw new RuntimeException("malformed ref [" + ref + "] for <hint>");
		}
	} else {
	    q.setHelpInnerText(hintInnerText);
		q.setHelpText(hint);
	}

	if(XFormUtils.showUnusedAttributeWarning(e, usedAtts)){
		reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:26,代码来源:XFormParser.java

示例6: getVagueElementPrintout

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public static String getVagueElementPrintout(Element e, int maxDepth) {
	String elementString = "<" + e.getName();
	for(int i = 0; i <  e.getAttributeCount() ; ++i) {
		elementString += " " + e.getAttributeName(i) + "=\"";
		elementString += e.getAttributeValue(i) + "\"";
	}
	if(e.getChildCount() > 0) {
		elementString += ">";
		if(e.getType(0) ==Element.ELEMENT) {
			if(maxDepth > 0) {
				elementString += getVagueElementPrintout((Element)e.getChild(0),maxDepth -1);
			} else {
				elementString += "...";
			}
		}
	} else {
		elementString += "/>";
	}
	return elementString;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:21,代码来源:XFormParser.java

示例7: parse

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public QuestionDataExtension parse(Element elt) {
    String s = elt.getAttributeValue(XFormParser.NAMESPACE_JAVAROSA,
            "imageDimensionScaledMax");
    if (s != null) {
        if (s.endsWith("px")) {
            s = s.substring(0, s.length() - 2);
        }
        try {
            int maxDimens = Integer.parseInt(s);
            return new UploadQuestionExtension(maxDimens);
        } catch (NumberFormatException e) {
            throw new XFormParseException("Invalid input for image max dimension: " + s);
        }
    }
    return null;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:17,代码来源:UploadQuestionExtensionParser.java

示例8: parseUpload

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
protected QuestionDef parseUpload(IFormElement parent, Element e, int controlUpload) {
    Vector<String> usedAtts = new Vector<String>();
    usedAtts.addElement("mediatype");

    QuestionDef question = parseControl(parent, e, controlUpload, usedAtts);

    String mediaType = e.getAttributeValue(null, "mediatype");
    if ("image/*".equals(mediaType)) {
        // NOTE: this could be further expanded. 
        question.setControlType(Constants.CONTROL_IMAGE_CHOOSE);
    } else if ("audio/*".equals(mediaType)) {
        question.setControlType(Constants.CONTROL_AUDIO_CAPTURE);
    } else if ("video/*".equals(mediaType)) {
        question.setControlType(Constants.CONTROL_VIDEO_CAPTURE);
    }

    return question;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:19,代码来源:XFormParser.java

示例9: parseItemsetLabelElement

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private void parseItemsetLabelElement(Element child, ItemsetBinding itemset, Vector<String> labelUA) {
    String labelXpath = child.getAttributeValue("", REF_ATTR);
    boolean labelItext = false;

    if (XFormUtils.showUnusedAttributeWarning(child, labelUA)) {
        reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(child, labelUA), getVagueLocation(child));
    }

    if (labelXpath != null) {
        if (labelXpath.startsWith("jr:itext(") && labelXpath.endsWith(")")) {
            labelXpath = labelXpath.substring("jr:itext(".length(), labelXpath.indexOf(")"));
            labelItext = true;
        }
    } else {
        throw new XFormParseException("<label> in <itemset> requires 'ref'");
    }

    XPathPathExpr labelPath = XPathReference.getPathExpr(labelXpath);
    itemset.labelRef = FormInstance.unpackReference(getAbsRef(new XPathReference(labelPath), itemset.nodesetRef));
    itemset.labelExpr = new XPathConditional(labelPath);
    itemset.labelIsItext = labelItext;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:23,代码来源:XFormParser.java

示例10: getVagueElementPrintout

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public static String getVagueElementPrintout(Element e, int maxDepth) {
    String elementString = "<" + e.getName();
    for (int i = 0; i < e.getAttributeCount(); ++i) {
        elementString += " " + e.getAttributeName(i) + "=\"";
        elementString += e.getAttributeValue(i) + "\"";
    }
    if (e.getChildCount() > 0) {
        elementString += ">";
        if (e.getType(0) == Element.ELEMENT) {
            if (maxDepth > 0) {
                elementString += getVagueElementPrintout((Element)e.getChild(0), maxDepth - 1);
            } else {
                elementString += "...";
            }
        }
    } else {
        elementString += "/>";
    }
    return elementString;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:21,代码来源:XFormParser.java

示例11: parseUpload

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
protected QuestionDef parseUpload(IFormElement parent, Element e, int controlUpload) {
    Vector<String> usedAtts = new Vector<>();
    usedAtts.addElement("mediatype");

    QuestionDef question = parseControl(parent, e, controlUpload, usedAtts);

    String mediaType = e.getAttributeValue(null, "mediatype");
    if ("image/*".equals(mediaType)) {
        // NOTE: this could be further expanded. 
        question.setControlType(Constants.CONTROL_IMAGE_CHOOSE);
    } else if ("audio/*".equals(mediaType)) {
        question.setControlType(Constants.CONTROL_AUDIO_CAPTURE);
    } else if ("video/*".equals(mediaType)) {
        question.setControlType(Constants.CONTROL_VIDEO_CAPTURE);
    }

    return question;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:19,代码来源:XFormParser.java

示例12: parse

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
@Override
public QuestionDataExtension parse(Element elt) {
    String s = elt.getAttributeValue(XFormParser.NAMESPACE_JAVAROSA,
            "imageDimensionScaledMax");
    if (s != null) {
        if (s.endsWith("px")) {
            s = s.substring(0, s.length() - 2);
        }
        try {
            int maxDimens = Integer.parseInt(s);
            return new UploadQuestionExtension(maxDimens);
        } catch (NumberFormatException e) {
            throw new XFormParseException("Invalid input for image max dimension: " + s);
        }
    }
    return null;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:18,代码来源:UploadQuestionExtensionParser.java

示例13: parseMeta

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private void parseMeta(Element e) {
    Vector<String> usedAtts = new Vector<>();
    int attributes = e.getAttributeCount();
    for (int i = 0; i < attributes; ++i) {
        String name = e.getAttributeName(i);
        String value = e.getAttributeValue(i);
        if ("name".equals(name)) {
            _f.setName(value);
        }
    }


    usedAtts.addElement("name");
    if (XFormUtils.showUnusedAttributeWarning(e, usedAtts)) {
        reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:18,代码来源:XFormParser.java

示例14: parseAction

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
/**
 * Generic parse method that all actions get passed through. Checks that the action element's
 * event attribute and location in the xform are both valid, and then invokes the more specific
 * handler that is provided.
 */
private void parseAction(Element e, Object parent, IElementHandler specificHandler) {
    // Check that the event registered to trigger this action is a valid event that we support
    String event = e.getAttributeValue(null, EVENT_ATTR);
    if (!Action.isValidEvent(event)) {
        throw new XFormParseException("An action was registered for an unsupported event: " + event);
    }

    // Check that the action was included in a valid place within the XForm
    if (!(parent instanceof IFormElement)) {
        // parent must either be a FormDef or QuestionDef, both of which are IFormElements
        throw new XFormParseException("An action element occurred in an invalid location. " +
                "Must be either a child of a control element, or a child of the <model>");
    }

    specificHandler.handle(this, e, parent);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:22,代码来源:XFormParser.java

示例15: getBindingAttributeValue

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private static String getBindingAttributeValue(List<Element> bindings,
    String attributeNamespace, String attributeName) {
  String retval = null;

  for (int i = 0; i < bindings.size(); i++) {
    Element element = bindings.get(i);
    if ((retval = element.getAttributeValue(attributeNamespace, attributeName)) != null) {
      return (retval);
    }
  }
  return (retval);
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:13,代码来源:BaseFormParserForJavaRosa.java


注:本文中的org.kxml2.kdom.Element.getAttributeValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。