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


Java Element.setNamespace方法代码示例

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


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

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

示例2: visit

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public void visit(FormInstance tree) {
	theXmlDoc = new Document();
	//TreeElement root = tree.getRoot();

	TreeElement root = tree.resolveReference(rootRef);

	//For some reason resolveReference won't ever return the root, so we'll
	//catch that case and just start at the root.
	if(root == null) {
		root = tree.getRoot();
	}

	if (root != null) {
		theXmlDoc.addChild(Node.ELEMENT, serializeNode(root));
	}

	Element top = theXmlDoc.getElement(0);

	String[] prefixes = tree.getNamespacePrefixes();
	for(int i = 0 ; i < prefixes.length; ++i ) {
		top.setPrefix(prefixes[i], tree.getNamespaceURI(prefixes[i]));
	}
	if (tree.schema != null) {
		top.setNamespace(tree.schema);
		top.setPrefix("", tree.schema);
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:28,代码来源:XFormSerializingVisitor.java

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

示例4: 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:dimagi,项目名称:commcare-j2me,代码行数:31,代码来源:InstanceSchema.java

示例5: visit

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
@Override
public void visit(FormInstance tree) {
    theXmlDoc = new Document();

    TreeElement root = tree.resolveReference(rootRef);

    //For some reason resolveReference won't ever return the root, so we'll
    //catch that case and just start at the root.
    if (root == null) {
        root = tree.getRoot();
    }

    if (root != null) {
        theXmlDoc.addChild(Node.ELEMENT, serializeNode(root));
    }

    Element top = theXmlDoc.getElement(0);

    String[] prefixes = tree.getNamespacePrefixes();
    for (String prefix : prefixes) {
        top.setPrefix(prefix, tree.getNamespaceURI(prefix));
    }
    if (tree.schema != null) {
        top.setNamespace(tree.schema);
        top.setPrefix("", tree.schema);
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:28,代码来源:XFormSerializingVisitor.java

示例6: parse

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
@Override
public FormRecord parse() throws InvalidStructureException, IOException, XmlPullParserException {
    String xmlns = parser.getNamespace();
    //Parse this subdocument into a dom
    Element element = new Element();
    element.setName(parser.getName());
    element.setNamespace(parser.getNamespace());
    element.parse(this.parser);

    //Consume the end tag.
    //this.parser.next();

    //create an actual document out of it.
    Document document = new Document();
    document.addChild(Node.ELEMENT, element);

    KXmlSerializer serializer = new KXmlSerializer();

    String filePath = getInstanceDestination(namespaceToInstallPath.get(xmlns));

    //Register this instance for inspection
    ContentValues values = new ContentValues();
    values.put(InstanceColumns.DISPLAY_NAME, "Historical Form");
    values.put(InstanceColumns.SUBMISSION_URI, "");
    values.put(InstanceColumns.INSTANCE_FILE_PATH, filePath);
    values.put(InstanceColumns.JR_FORM_ID, xmlns);
    values.put(InstanceColumns.STATUS, InstanceProviderAPI.STATUS_COMPLETE);
    values.put(InstanceColumns.CAN_EDIT_WHEN_COMPLETE, false);

    // Unindexed flag tells content provider to link this instance to a
    // new, unindexed form record that isn't attached to the
    // AndroidSessionWrapper
    values.put(InstanceProviderAPI.UNINDEXED_SUBMISSION, true);

    Uri instanceRecord =
            c.getContentResolver().insert(InstanceColumns.CONTENT_URI, values);

    // Find the form record attached to the form instance during insertion
    IStorageUtilityIndexed<FormRecord> storage = cachedStorage();
    FormRecord attachedRecord =
            storage.getRecordForValue(FormRecord.META_INSTANCE_URI,
                    instanceRecord.toString());

    if (attachedRecord == null) {
        throw new RuntimeException("No FormRecord was attached to the inserted form instance");
    }

    OutputStream o = new FileOutputStream(filePath);
    BufferedOutputStream bos = null;

    try {
        Cipher encrypter = Cipher.getInstance("AES");

        SecretKeySpec key = new SecretKeySpec(attachedRecord.getAesKey(), "AES");
        encrypter.init(Cipher.ENCRYPT_MODE, key);
        CipherOutputStream cos = new CipherOutputStream(o, encrypter);
        bos = new BufferedOutputStream(cos, 1024 * 256);

        serializer.setOutput(bos, "UTF-8");

        document.write(serializer);
    } catch (InvalidKeyException | NoSuchPaddingException | NoSuchAlgorithmException e) {
        // writing the form instance to xml failed, so remove the record
        storage.remove(attachedRecord);
        throw new RuntimeException(e.getMessage());
    } finally {
        //since bos might not have even been created.
        if (bos != null) {
            bos.close();
        } else {
            o.close();
        }
    }
    return attachedRecord;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:76,代码来源:FormInstanceXmlParser.java


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