本文整理汇总了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();
}
示例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();
}
示例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);
}
}
示例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;
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}