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


Java Node类代码示例

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


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

示例1: generateXmlManifestList

import org.kxml2.kdom.Node; //导入依赖的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.Node; //导入依赖的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.Node; //导入依赖的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.Node; //导入依赖的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: getXMLText

import org.kxml2.kdom.Node; //导入依赖的package包/类
/**
* reads all subsequent text nodes and returns the combined string
* needed because escape sequences are parsed into consecutive text nodes
* e.g. "abc&amp;123" --> (abc)(&)(123)
**/
public static String getXMLText (Node node, int i, boolean trim) {
	StringBuilder strBuff = null;

	String text = node.getText(i);
	if (text == null)
		return null;

	for (i++; i < node.getChildCount() && node.getType(i) == Node.TEXT; i++) {
		if (strBuff == null)
			strBuff = new StringBuilder(text);

		strBuff.append(node.getText(i));
	}
	if (strBuff != null)
		text = strBuff.toString();

	if (trim)
		text = text.trim();

	return text;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:27,代码来源:XFormParser.java

示例6: writeChoices

import org.kxml2.kdom.Node; //导入依赖的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: parseControlChildren

import org.kxml2.kdom.Node; //导入依赖的package包/类
private void parseControlChildren(Element e, QuestionDef question, IFormElement parent,
                                  boolean isSelect) {
    for (int i = 0; i < e.getChildCount(); i++) {
        int type = e.getType(i);
        Element child = (type == Node.ELEMENT ? e.getElement(i) : null);
        if (child == null) {
            continue;
        }
        String childName = child.getName();

        if (LABEL_ELEMENT.equals(childName) || HINT_ELEMENT.equals(childName)
                || HELP_ELEMENT.equals(childName) || CONSTRAINT_ELEMENT.equals(childName)) {
            parseHelperText(question, child);
        } else if (isSelect && "item".equals(childName)) {
            parseItem(question, child);
        } else if (isSelect && "itemset".equals(childName)) {
            parseItemset(question, child);
        } else if (actionHandlers.containsKey(childName)) {
            actionHandlers.get(childName).handle(this, child, question);
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:23,代码来源:XFormParser.java

示例8: getXMLText

import org.kxml2.kdom.Node; //导入依赖的package包/类
/**
 * reads all subsequent text nodes and returns the combined string
 * needed because escape sequences are parsed into consecutive text nodes
 * e.g. "abc&amp;123" --> (abc)(&)(123)
 */
public static String getXMLText(Node node, int i, boolean trim) {
    StringBuffer strBuff = null;

    String text = node.getText(i);
    if (text == null)
        return null;

    for (i++; i < node.getChildCount() && node.getType(i) == Node.TEXT; i++) {
        if (strBuff == null)
            strBuff = new StringBuffer(text);

        strBuff.append(node.getText(i));
    }
    if (strBuff != null)
        text = strBuff.toString();

    if (trim)
        text = text.trim();

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

示例9: addSecurityHeader

import org.kxml2.kdom.Node; //导入依赖的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

示例10: executeNodeSet

import org.kxml2.kdom.Node; //导入依赖的package包/类
public boolean executeNodeSet() {
    Node context = defaultContextNode;

    errorInNodeSet = false;
    nodesetExecuted = true;
    try {
        nodeSetResult = nodeSetExpr.evaluate(context, XPathResult.ANY);
    } catch (Exception e) {
        // TODO: error handling, e.g. a specific subclass of 
        // exception for erroneous XPath expressions?
        System.err.println(e.getMessage());
        errorInNodeSet = true;
    }
    if (nodeSetResult != null) {
        errorInNodeSet =  (nodeSetResult.getType() != XPathResult.NODESET);
        nodeSet = nodeSetResult.asNodeSet();
    }
    return !errorInNodeSet;
}
 
开发者ID:okoskimi,项目名称:Xfolite,代码行数:20,代码来源:Bind.java

示例11: getChildElement

import org.kxml2.kdom.Node; //导入依赖的package包/类
private static Element getChildElement(Element parent, String childName) {
    Element e = null;
    int c = parent.getChildCount();
    int i = 0;
    for (i = 0; i < c; i++) {
        if (parent.getType(i) == Node.ELEMENT) {
            if (parent.getElement(i).getName().equalsIgnoreCase(childName)) {
                return parent.getElement(i);
            }
        }
    }
    return e;
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:14,代码来源:FileUtils.java

示例12: generateManifestXmlEntry

import org.kxml2.kdom.Node; //导入依赖的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

示例13: emitXmlWrappedCsv

import org.kxml2.kdom.Node; //导入依赖的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

示例14: generateInstanceSchema

import org.kxml2.kdom.Node; //导入依赖的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

示例15: writeListType

import org.kxml2.kdom.Node; //导入依赖的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


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