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


Java Element.getNamespace方法代码示例

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


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

示例1: parseInstance

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private FormInstance parseInstance(Element e, boolean isMainInstance) {
    String name = instanceNodeIdStrs.elementAt(instanceNodes.indexOf(e));

    TreeElement root = buildInstanceStructure(e, null, !isMainInstance ? name : null, e.getNamespace());
    FormInstance instanceModel = new FormInstance(root, !isMainInstance ? name : null);
    if (isMainInstance) {
        instanceModel.setName(_f.getTitle());
    } else {
        instanceModel.setName(name);
    }

    Vector<String> usedAtts = new Vector<String>();
    usedAtts.addElement("version");
    usedAtts.addElement("uiVersion");
    usedAtts.addElement("name");

    String schema = e.getNamespace();
    if (schema != null && schema.length() > 0 && !schema.equals(defaultNamespace)) {
        instanceModel.schema = schema;
    }
    instanceModel.formVersion = e.getAttributeValue(null, "version");
    instanceModel.uiVersion = e.getAttributeValue(null, "uiVersion");

    loadNamespaces(e, instanceModel);
    if (isMainInstance) {
        processRepeats(instanceModel);
        verifyBindings(instanceModel);
        verifyActions(instanceModel);
    }
    applyInstanceProperties(instanceModel);

    //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));
    }

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

示例2: parseInstance

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private FormInstance parseInstance(Element e, boolean isMainInstance) {
    String name = instanceNodeIdStrs.elementAt(instanceNodes.indexOf(e));

    TreeElement root = buildInstanceStructure(e, null, !isMainInstance ? name : null, e.getNamespace());
    FormInstance instanceModel = new FormInstance(root, !isMainInstance ? name : null);
    if (isMainInstance) {
        instanceModel.setName(_f.getTitle());
    } else {
        instanceModel.setName(name);
    }

    Vector<String> usedAtts = new Vector<>();
    usedAtts.addElement("version");
    usedAtts.addElement("uiVersion");
    usedAtts.addElement("name");

    String schema = e.getNamespace();
    if (schema != null && schema.length() > 0 && !schema.equals(defaultNamespace)) {
        instanceModel.schema = schema;
    }
    instanceModel.formVersion = e.getAttributeValue(null, "version");
    instanceModel.uiVersion = e.getAttributeValue(null, "uiVersion");

    loadNamespaces(e, instanceModel);
    if (isMainInstance) {
        processRepeats(instanceModel);
        verifyBindings(instanceModel);
        verifyActions(instanceModel);
    }
    applyInstanceProperties(instanceModel);

    //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));
    }

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

示例3: parseInstance

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private FormInstance parseInstance (Element e, boolean isMainInstance) {
	String name = instanceNodeIdStrs.get(instanceNodes.indexOf(e));

	TreeElement root = buildInstanceStructure(e, null, !isMainInstance ? name : null, e.getNamespace());
	FormInstance instanceModel = new FormInstance(root);
	if(isMainInstance)
	{
		instanceModel.setName(_f.getTitle());
	}
	else
	{
		instanceModel.setName(name);
	}

     List<String> usedAtts = new ArrayList<String>();
	usedAtts.add("id");
	usedAtts.add("version");
	usedAtts.add("uiVersion");
	usedAtts.add("name");

	String schema = e.getNamespace();
	if (schema != null && schema.length() > 0 && !schema.equals(defaultNamespace)) {
		instanceModel.schema = schema;
	}
	instanceModel.formVersion = e.getAttributeValue(null, "version");
	instanceModel.uiVersion = e.getAttributeValue(null, "uiVersion");

	loadNamespaces(e, instanceModel);
	if(isMainInstance)
	{
		processRepeats(instanceModel);
		verifyBindings(instanceModel);
		verifyActions(instanceModel);
	}
	applyInstanceProperties(instanceModel);

	//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));
	}

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

示例4: parseElement

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
/**
 * @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
 */
private void parseElement(Element e, Object parent, Hashtable<String, IElementHandler> handlers) {
    String name = e.getName();
    String namespace = e.getNamespace();

    String[] suppressWarningArr = {
            "html",
            "head",
            "body",
            "xform",
            "chooseCaption",
            "addCaption",
            "addEmptyCaption",
            "delCaption",
            "doneCaption",
            "doneEmptyCaption",
            "mainHeader",
            "entryHeader",
            "delHeader"
    };
    Vector<String> suppressWarning = new Vector<String>();
    for (int i = 0; i < suppressWarningArr.length; i++) {
        suppressWarning.addElement(suppressWarningArr[i]);
    }

    // if there is a registered parser, invoke it
    IElementHandler eh = handlers.get(name);
    if (eh != null) {
        eh.handle(this, e, parent);
    } else {
        if (inSpecExtension(namespace, name)) {
            parseUnregisteredSpecExtension(namespace, name, e, parent, handlers);
        } else {
            if (!suppressWarning.contains(name)) {
                reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP,
                        "Unrecognized element [" + name + "]. Ignoring and processing children...",
                        getVagueLocation(e));
            }
            // parse children
            for (int i = 0; i < e.getChildCount(); i++) {
                if (e.getType(i) == Element.ELEMENT) {
                    parseElement(e.getElement(i), parent, handlers);
                }
            }
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:52,代码来源:XFormParser.java

示例5: parseElement

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
/**
 * @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
 */
private void parseElement(Element e, Object parent, Hashtable<String, IElementHandler> handlers) {
    String name = e.getName();
    String namespace = e.getNamespace();

    String[] suppressWarningArr = {
            "html",
            "head",
            "body",
            "xform",
            "chooseCaption",
            "addCaption",
            "addEmptyCaption",
            "delCaption",
            "doneCaption",
            "doneEmptyCaption",
            "mainHeader",
            "entryHeader",
            "delHeader"
    };
    Vector<String> suppressWarning = new Vector<>();
    for (String aSuppressWarningArr : suppressWarningArr) {
        suppressWarning.addElement(aSuppressWarningArr);
    }

    // if there is a registered parser, invoke it
    IElementHandler eh = handlers.get(name);
    if (eh != null) {
        eh.handle(this, e, parent);
    } else {
        if (inSpecExtension(namespace, name)) {
            parseUnregisteredSpecExtension(namespace, name, e, parent, handlers);
        } else {
            if (!suppressWarning.contains(name)) {
                reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP,
                        "Unrecognized element [" + name + "]. Ignoring and processing children...",
                        getVagueLocation(e));
            }
            // parse children
            for (int i = 0; i < e.getChildCount(); i++) {
                if (e.getType(i) == Element.ELEMENT) {
                    parseElement(e.getElement(i), parent, handlers);
                }
            }
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:52,代码来源:XFormParser.java

示例6: buildInstanceStructure

import org.kxml2.kdom.Element; //导入方法依赖的package包/类
/** parse instance hierarchy and turn into a skeleton model; ignoring data content, but respecting repeated nodes and 'template' flags */
public static TreeElement buildInstanceStructure(Element node, TreeElement parent, String instanceName, String docnamespace) {
    TreeElement element = null;

    //catch when text content is mixed with children
    int numChildren = node.getChildCount();
    boolean hasText = false;
    boolean hasElements = false;
    for (int i = 0; i < numChildren; i++) {
        switch (node.getType(i)) {
            case Node.ELEMENT:
                hasElements = true;
                break;
            case Node.TEXT:
                if (node.getText(i).trim().length() > 0)
                    hasText = true;
                break;
        }
    }
    if (hasElements && hasText) {
        System.out.println("Warning: instance node '" + node.getName() + "' contains both elements and text as children; text ignored");
    }

    //check for repeat templating
    String name = node.getName();
    int multiplicity;
    if (node.getAttributeValue(NAMESPACE_JAVAROSA, "template") != null) {
        multiplicity = TreeReference.INDEX_TEMPLATE;
        if (parent != null && parent.getChild(name, TreeReference.INDEX_TEMPLATE) != null) {
            throw new XFormParseException("More than one node declared as the template for the same repeated set [" + name + "]", node);
        }
    } else {
        multiplicity = (parent == null ? 0 : parent.getChildMultiplicity(name));
    }


    String modelType = node.getAttributeValue(NAMESPACE_JAVAROSA, "modeltype");
    //create node; handle children
    if (modelType == null) {
        element = new TreeElement(name, multiplicity);
        element.setInstanceName(instanceName);
    } else {
        if (typeMappings.get(modelType) == null) {
            throw new XFormParseException("ModelType " + modelType + " is not recognized.", node);
        }
        element = new TreeElement(name, multiplicity);
    }
    if (node.getNamespace() != null) {
        if (!node.getNamespace().equals(docnamespace)) {
            element.setNamespace(node.getNamespace());
        }
    }


    if (hasElements) {
        for (int i = 0; i < numChildren; i++) {
            if (node.getType(i) == Node.ELEMENT) {
                element.addChild(buildInstanceStructure(node.getElement(i), element, instanceName, docnamespace));
            }
        }
    }

    //handle attributes
    if (node.getAttributeCount() > 0) {
        for (int i = 0; i < node.getAttributeCount(); i++) {
            String attrNamespace = node.getAttributeNamespace(i);
            String attrName = node.getAttributeName(i);
            if (attrNamespace.equals(NAMESPACE_JAVAROSA) && attrName.equals("template")) {
                continue;
            }
            if (attrNamespace.equals(NAMESPACE_JAVAROSA) && attrName.equals("recordset")) {
                continue;
            }

            element.setAttribute(attrNamespace, attrName, node.getAttributeValue(i));
        }
    }

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


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