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


Java Element.addChild方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: addSecurityHeader

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
void addSecurityHeader(SoapSerializationEnvelope envelope){
    Element headers[] = new Element[1];
    headers[0]= new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security");
    headers[0].setAttribute(envelope.env, "mustUnderstand", "1");
    Element security=headers[0];

    Element token = new Element().createElement(security.getNamespace(), "UsernameToken");
    token.setAttribute("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "Id", "UsernameToken-2");

    Element username = new Element().createElement(security.getNamespace(), "Username");
    username.addChild(Node.TEXT, USERNAME);
    token.addChild(Node.ELEMENT,username);

    Element password = new Element().createElement(security.getNamespace(), "Password");
    password.setAttribute(null, "Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
    password.addChild(Node.TEXT, USERPASSWORD);
    token.addChild(Node.ELEMENT,password);
    
    headers[0].addChild(Node.ELEMENT, token);

    envelope.headerOut = headers;
}
 
开发者ID:mmprog,项目名称:wspocztapolska,代码行数:23,代码来源:WSPoczta.java

示例8: generateManifestXmlEntry

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private int generateManifestXmlEntry(Document d, Element e, int idx, String uri, BinaryContentManipulator m, int i, CallingContext cc) throws ODKDatastoreException {
    String filename = m.getUnrootedFilename(i, cc);
    String hash = m.getContentHash(i, cc);

    // if we don't have the file (hash==null), then don't emit anything.
    if ( hash == null ) return idx;
    
    int feIdx = 0;
    Element fileEntryElement = d.createElement(XML_TAG_NAMESPACE, XFormsTableConsts.MEDIA_FILE_TAG);
    e.addChild(idx++, Node.ELEMENT, fileEntryElement);
    Element fileNameElement = d.createElement(XML_TAG_NAMESPACE, XFormsTableConsts.FILE_NAME_TAG);
    fileEntryElement.addChild(feIdx++, Node.ELEMENT, fileNameElement);
    fileNameElement.addChild(0, Node.TEXT, filename);
    Element hashElement = d.createElement(XML_TAG_NAMESPACE, XFormsTableConsts.HASH_TAG);
    fileEntryElement.addChild(feIdx++, Node.ELEMENT, hashElement);
    hashElement.addChild(0, Node.TEXT, hash);
    Element downloadElement = d.createElement(XML_TAG_NAMESPACE, XFormsTableConsts.DOWNLOAD_URL_TAG);
    fileEntryElement.addChild(feIdx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);
    fileEntryElement.addChild(feIdx++, Node.ELEMENT, downloadElement);
    {
      Map<String, String> properties = new HashMap<String, String>();
      SubmissionKey k = FormInfo.getManifestSubmissionKey(uri, i);
      properties.put(ServletConsts.BLOB_KEY, k.toString());
      properties.put(ServletConsts.AS_ATTACHMENT, "true");
      String urlLink = HtmlUtil.createLinkWithProperties(downloadRequestURL, properties);
      downloadElement.addChild(0, Node.TEXT, urlLink);
    }
    e.addChild(idx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);
    return idx;
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:31,代码来源:XFormsManifestXmlTable.java

示例9: emitXmlWrappedCsv

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private void emitXmlWrappedCsv(List<Row> resultTable, List<String> headers) throws IOException {

    Document d = new Document();
    d.setStandalone(true);
    d.setEncoding(HtmlConsts.UTF8_ENCODE);
    Element e = d.createElement(XML_TAG_NAMESPACE, XML_TAG_ENTRIES);
    d.addChild(0, Node.ELEMENT, e);
    int idx = 0;
    e.addChild(idx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);
    if (websafeCursorString != null) {
      Element cursor = d.createElement(XML_TAG_NAMESPACE, XML_TAG_CURSOR);
      e.addChild(idx++, Node.ELEMENT, cursor);
      cursor.addChild(0, Node.TEXT, websafeCursorString);
      e.addChild(idx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);
    }
    Element header = d.createElement(XML_TAG_NAMESPACE, XML_TAG_HEADER);
    e.addChild(idx++, Node.ELEMENT, header);
    header.addChild(0, Node.TEXT, generateCommaSeperatedElements(headers));
    e.addChild(idx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);

    Element resultRow;
    // generate rows
    for (Row row : resultTable) {
      resultRow = d.createElement(XML_TAG_NAMESPACE, XML_TAG_RESULT);
      e.addChild(idx++, Node.ELEMENT, resultRow);
      String csvRow = generateCommaSeperatedElements(row.getFormattedValues());
      resultRow.addChild(0, Node.TEXT, csvRow);
      e.addChild(idx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);
    }

    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,代码行数:38,代码来源:FragmentedCsvFormatter.java

示例10: generateInstanceSchema

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public static Document generateInstanceSchema (FormDef f) {
	init();

	Element schema = new Element();
	schema.setName("schema");
	schema.setNamespace("http://www.w3.org/2001/XMLSchema");
	schema.setPrefix("", "http://www.w3.org/2001/XMLSchema");
	schema.setPrefix("jr", "http://openrosa.org/javarosa");
	if (f.getInstance().schema != null) {
		schema.setAttribute(null, "targetNamespace", f.getInstance().schema);
	} else {
		System.err.println("Warning: instance has no schema");
	}
	schema.setAttribute(null, "elementFormDefault", "qualified");

	String formVersion = f.getInstance().formVersion;
	String uiVersion = f.getInstance().uiVersion;
	if (formVersion != null)
		schema.setAttribute(null, "version", formVersion);
	if (uiVersion != null)
		schema.setAttribute(null, "uiVersion", uiVersion);

	processSelectChoices(schema, f, f);
	schema.addChild(Node.ELEMENT, schemizeInstance(f.getInstance().getRoot()));

	Document schemaXML = new Document();
	schemaXML.addChild(Node.ELEMENT, schema);

	return schemaXML;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:31,代码来源:InstanceSchema.java

示例11: writeListType

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private static void writeListType (Element e, String typeName) {
	Element st = new Element();
	st.setName("simpleType");
	st.setAttribute(null, "name", "list." + typeName);
	e.addChild(Node.ELEMENT, st);

	Element list = new Element();
	list.setName("list");
	list.setAttribute(null, "itemType", typeName);
	st.addChild(Node.ELEMENT, list);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:12,代码来源:InstanceSchema.java

示例12: buildAuthHeader

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private static Element buildAuthHeader() {
    Element h = new Element().createElement(NAMESPACE, "soapGuvenlik");
    Element username = new Element().createElement(NAMESPACE, "KullaniciAdi");
    username.addChild(Node.TEXT, USERNAME);
    h.addChild(Node.ELEMENT, username);
    Element pass = new Element().createElement(NAMESPACE, "Sifre");
    pass.addChild(Node.TEXT, PASSWORD);
    h.addChild(Node.ELEMENT, pass);

    return h;
}
 
开发者ID:Arciles,项目名称:BLKMobile,代码行数:12,代码来源:RequestSoap.java

示例13: createXmlRegistrationDoc

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private Document createXmlRegistrationDoc(User u) {
    Document document = new Document();
    Element root = document.createElement(null,"registration");
    root.setNamespace(XMLNS_UR);

    addChildWithText(root,"username",u.getUsername());

    addChildWithText(root,"password",u.getPasswordHash());
    addChildWithText(root,"uuid",u.getUniqueId());

    addChildWithText(root,"date",DateUtils.formatDate(new Date(),DateUtils.FORMAT_ISO8601));

    addChildWithText(root, "registering_phone_id",PropertyManager._().getSingularProperty(JavaRosaPropertyRules.DEVICE_ID_PROPERTY));


    Element userData =  root.createElement(null,"user_data");

    for(Enumeration en = u.listProperties(); en.hasMoreElements() ;) {
        String property = (String)en.nextElement();
        Element data= userData.createElement(null,"data");
        data.setAttribute(null,"key",property);
        data.addChild(Element.TEXT, u.getProperty(property));
        userData.addChild(Element.ELEMENT, data);
    }
    root.addChild(Element.ELEMENT,userData);
    document.addChild(Element.ELEMENT, root);
    return document;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:29,代码来源:HttpUserRegistrationTranslator.java

示例14: serializeLog

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private Element serializeLog(LogEntry log) {
    Element entry = new Element();
    entry.setName("log");
    entry.setAttribute(null, "date", DateUtils.formatDateTime(log.getTime(), DateUtils.FORMAT_ISO8601));

    Element type = entry.createElement(null,"type");
    type.addChild(Element.TEXT, log.getType());
    entry.addChild(Element.ELEMENT, type);

    Element message = entry.createElement(null,"msg");
    message.addChild(Element.TEXT, log.getMessage());
    entry.addChild(Element.ELEMENT, message);

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

示例15: serializeLogs

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public Element serializeLogs(LogEntry[] logs) {
    Element report = new Element();
    report.setName(topElementName);
    for(int i = 0; i < logs.length; ++i ) {
        report.addChild(Element.ELEMENT, this.serializeLog(logs[i]));
    }
    return report;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:9,代码来源:XmlLogSerializer.java


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