本文整理汇总了Java中org.kxml2.kdom.Element类的典型用法代码示例。如果您正苦于以下问题:Java Element类的具体用法?Java Element怎么用?Java Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Element类属于org.kxml2.kdom包,在下文中一共展示了Element类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: generateXmlManifestList
import org.kxml2.kdom.Element; //导入依赖的package包/类
public void generateXmlManifestList(PrintWriter output, CallingContext cc) throws IOException, ODKDatastoreException {
Document d = new Document();
d.setStandalone(true);
d.setEncoding(HtmlConsts.UTF8_ENCODE);
Element e = d.createElement(XML_TAG_NAMESPACE, XFormsTableConsts.MANIFEST_TAG);
e.setPrefix(null, XML_TAG_NAMESPACE);
d.addChild(0, Node.ELEMENT, e);
int idx = 0;
e.addChild(idx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);
// build XML table of form information
BinaryContentManipulator manifest = form.getManifestFileset();
if ( manifest != null ) {
int fileCount = manifest.getAttachmentCount(cc);
for ( int i = 1 ; i <= fileCount ; ++i ) {
idx = generateManifestXmlEntry(d, e, idx, form.getUri(), manifest, i, cc);
}
}
KXmlSerializer serializer = new KXmlSerializer();
serializer.setOutput(output);
// setting the response content type emits the xml header.
// just write the body here...
d.writeChildren(serializer);
serializer.flush();
}
开发者ID:opendatakit,项目名称:aggregate,代码行数:27,代码来源:XFormsManifestXmlTable.java
示例3: generateXmlListOfForms
import org.kxml2.kdom.Element; //导入依赖的package包/类
public void generateXmlListOfForms(PrintWriter output, CallingContext cc) throws IOException, ODKDatastoreException {
Document d = new Document();
d.setStandalone(true);
d.setEncoding(HtmlConsts.UTF8_ENCODE);
Element e = d.createElement(XML_TAG_NAMESPACE, XFormsTableConsts.XFORMS_TAG);
e.setPrefix(null, XML_TAG_NAMESPACE);
d.addChild(0, Node.ELEMENT, e);
int idx = 0;
e.addChild(idx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);
// build XML table of form information
for (IForm form : forms) {
if (!form.hasValidFormDefinition() || !form.getDownloadEnabled())
continue;
idx = generateFormXmlEntry(d, e, idx, form, cc);
}
KXmlSerializer serializer = new KXmlSerializer();
serializer.setOutput(output);
// setting the response content type emits the xml header.
// just write the body here...
d.writeChildren(serializer);
serializer.flush();
}
开发者ID:opendatakit,项目名称:aggregate,代码行数:26,代码来源:XFormsXmlTable.java
示例4: writeChoices
import org.kxml2.kdom.Element; //导入依赖的package包/类
private static void writeChoices (Element e, String typeName, List<SelectChoice> choices) {
Element st = new Element();
st.setName("simpleType");
st.setAttribute(null, "name", typeName);
e.addChild(Node.ELEMENT, st);
Element restr = new Element();
restr.setName("restriction");
restr.setAttribute(null, "base", "string");
st.addChild(Node.ELEMENT, restr);
for (int i = 0; i < choices.size(); i++) {
String value = choices.get(i).getValue();
Element choice = new Element();
choice.setName("enumeration");
choice.setAttribute(null, "value", value);
restr.addChild(Node.ELEMENT, choice);
}
}
开发者ID:medic,项目名称:javarosa,代码行数:21,代码来源:InstanceSchema.java
示例5: parseTitle
import org.kxml2.kdom.Element; //导入依赖的package包/类
private void parseTitle (Element e) {
List<String> usedAtts = new ArrayList<String>(); //no attributes parsed in title.
String title = getXMLText(e, true);
System.out.println("Title: \"" + title + "\"");
_f.setTitle(title);
if(_f.getName() == null) {
//Jan 9, 2009 - ctsims
//We don't really want to allow for forms without
//some unique ID, so if a title is available, use
//that.
_f.setName(title);
}
if(XFormUtils.showUnusedAttributeWarning(e, usedAtts)){
reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
}
}
开发者ID:medic,项目名称:javarosa,代码行数:19,代码来源:XFormParser.java
示例6: 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
示例7: 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
示例8: 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
示例9: recurseForOutput
import org.kxml2.kdom.Element; //导入依赖的package包/类
private void recurseForOutput(Element e){
if(e.getChildCount() == 0) return;
for(int i=0;i<e.getChildCount();i++){
int kidType = e.getType(i);
if(kidType == Node.TEXT) { continue; }
if(e.getChild(i) instanceof String) { continue; }
Element kid = (Element)e.getChild(i);
//is just text
if(kidType == Node.ELEMENT && XFormUtils.isOutput(kid)){
String s = "${"+parseOutput(kid)+"}";
e.removeChild(i);
e.addChild(i, Node.TEXT, s);
//has kids? Recurse through them and swap output tag for parsed version
}else if(kid.getChildCount() !=0){
recurseForOutput(kid);
//is something else
}else{
continue;
}
}
}
开发者ID:medic,项目名称:javarosa,代码行数:25,代码来源:XFormParser.java
示例10: 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
示例11: parseIText
import org.kxml2.kdom.Element; //导入依赖的package包/类
private void parseIText (Element itext) {
Localizer l = new Localizer(true, true);
_f.setLocalizer(l);
l.registerLocalizable(_f);
ArrayList<String> usedAtts = new ArrayList<String>(); //used for warning message
for (int i = 0; i < itext.getChildCount(); i++) {
Element trans = itext.getElement(i);
if (trans == null || !trans.getName().equals("translation"))
continue;
parseTranslation(l, trans);
}
if (l.getAvailableLocales().length == 0)
throw new XFormParseException("no <translation>s defined",itext);
if (l.getDefaultLocale() == null)
l.setDefaultLocale(l.getAvailableLocales()[0]);
//print unused attribute warning message for parent element
if(XFormUtils.showUnusedAttributeWarning(itext, usedAtts)){
reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(itext, usedAtts), getVagueLocation(itext));
}
}
开发者ID:medic,项目名称:javarosa,代码行数:27,代码来源:XFormParser.java
示例12: addMainInstanceToFormDef
import org.kxml2.kdom.Element; //导入依赖的package包/类
private void addMainInstanceToFormDef(Element e, FormInstance instanceModel) {
//TreeElement root = buildInstanceStructure(e, null);
loadInstanceData(e, instanceModel.getRoot(), _f);
checkDependencyCycles();
_f.setInstance(instanceModel);
try {
_f.finalizeTriggerables();
} catch(IllegalStateException ise) {
throw new XFormParseException(ise.getMessage() == null ? "Form has an illegal cycle in its calculate and relevancy expressions!" : ise.getMessage());
}
//print unused attribute warning message for parent element
//if(XFormUtils.showUnusedAttributeWarning(e, usedAtts)){
// reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
//}
}
开发者ID:medic,项目名称:javarosa,代码行数:18,代码来源:XFormParser.java
示例13: 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
示例14: serializeAnswerData
import org.kxml2.kdom.Element; //导入依赖的package包/类
/**
* @param data The AnswerDataObject to be serialized
* @return A String which contains a reference to the
* data
*/
public Object serializeAnswerData(MultiPointerAnswerData data) {
//Note: In order to override this default behavior, a
//new serializer should be used, and then registered
//with this serializer
IDataPointer[] pointers = (IDataPointer[])data.getValue();
if(pointers.length == 1) {
return pointers[0].getDisplayText();
}
Element parent = new Element();
for(int i = 0; i < pointers.length; ++i) {
Element datael = new Element();
datael.setName("data");
datael.addChild(Element.TEXT, pointers[i].getDisplayText());
parent.addChild(Element.ELEMENT, datael);
}
return parent;
}
开发者ID:medic,项目名称:javarosa,代码行数:24,代码来源:XFormAnswerDataSerializer.java
示例15: elementToString
import org.kxml2.kdom.Element; //导入依赖的package包/类
public static String elementToString(Element e){
KXmlSerializer serializer = new KXmlSerializer();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
String s=null;
try {
serializer.setOutput(dos, null);
e.write(serializer);
serializer.flush();
s = new String(bos.toByteArray(),"UTF-8");
return s;
}catch (UnsupportedEncodingException uce){
uce.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
return null;
}
开发者ID:medic,项目名称:javarosa,代码行数:23,代码来源:XFormSerializer.java
示例16: writeChoices
import org.kxml2.kdom.Element; //导入依赖的package包/类
private static void writeChoices (Element e, String typeName, Vector<SelectChoice> choices) {
Element st = new Element();
st.setName("simpleType");
st.setAttribute(null, "name", typeName);
e.addChild(Node.ELEMENT, st);
Element restr = new Element();
restr.setName("restriction");
restr.setAttribute(null, "base", "string");
st.addChild(Node.ELEMENT, restr);
for (int i = 0; i < choices.size(); i++) {
String value = choices.elementAt(i).getValue();
Element choice = new Element();
choice.setName("enumeration");
choice.setAttribute(null, "value", value);
restr.addChild(Node.ELEMENT, choice);
}
}
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:21,代码来源:InstanceSchema.java
示例17: 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
示例18: parseUnregisteredSpecExtension
import org.kxml2.kdom.Element; //导入依赖的package包/类
/**
* Handle parsing and warning logic for a tag that doesn't have attached
* logic already, but has been registered as a spec extension.
*
* @param namespace String that is usually a url i.e. "http://opendatakit.org/xforms"
* @param name String representing tag name i.e. "extra" for an element like <extra ...>
* @param e is the current element we are parsing
* @param parent is the parent to the element we are parsing
* @param handlers maps tags to IElementHandlers, used to perform parsing of that tag
*/
public void parseUnregisteredSpecExtension(String namespace, String name, Element e, Object parent, Hashtable<String, IElementHandler> handlers) {
if (!XFormParser.suppressSpecExtensionWarnings.contains(namespace)) {
// raise a warning about not knowing how to parse
reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP,
"Unrecognized element [" + name + "] from namespace " + namespace + ".",
getVagueLocation(e));
}
if (XFormParser.parseSpecExtensionsInnerElements.contains(namespace)) {
// parse inner elements using default parsing logic.
for (int i = 0; i < e.getChildCount(); i++) {
if (e.getType(i) == Element.ELEMENT) {
parseElement(e.getElement(i), parent, handlers);
}
}
}
}
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:28,代码来源:XFormParser.java
示例19: parseTitle
import org.kxml2.kdom.Element; //导入依赖的package包/类
private void parseTitle(Element e) {
Vector<String> usedAtts = new Vector<String>(); //no attributes parsed in title.
String title = getXMLText(e, true);
System.out.println("Title: \"" + title + "\"");
_f.setTitle(title);
if (_f.getName() == null) {
//Jan 9, 2009 - ctsims
//We don't really want to allow for forms without
//some unique ID, so if a title is available, use
//that.
_f.setName(title);
}
if (XFormUtils.showUnusedAttributeWarning(e, usedAtts)) {
reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
}
}
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:19,代码来源:XFormParser.java
示例20: parseMeta
import org.kxml2.kdom.Element; //导入依赖的package包/类
private void parseMeta(Element e) {
Vector<String> usedAtts = new Vector<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.addElement("name");
if (XFormUtils.showUnusedAttributeWarning(e, usedAtts)) {
reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
}
}
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:18,代码来源:XFormParser.java
注:本文中的org.kxml2.kdom.Element类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论