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


Java Element.attributeIterator方法代码示例

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


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

示例1: parse

import org.dom4j.Element; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public StateLike parse(Element elem) {
    List<Element> infoElemList = elem.selectNodes(INFO_TAG);
    for (Element infoElem : infoElemList) {
        BizInfoElement bizInfoElement = new BizInfoElement();
        for (Iterator<Attribute> it = infoElem.attributeIterator(); it.hasNext(); ) {
            Attribute attribute = it.next();
            bizInfoElement.attribute.put(attribute.getName(), attribute.getValue());
        }
        String key = bizInfoElement.attribute.get(KEY_TAG);
        require(StringUtils.hasText(key), "attribute '" + KEY_TAG + "' in node bizInfo/info is required");
        if (bizInfoList.get(key) == null) {
            bizInfoList.put(key, new ArrayList<BizInfoElement>());
        }
        bizInfoList.get(key).add(bizInfoElement);
    }
    return this;
}
 
开发者ID:alibaba,项目名称:bulbasaur,代码行数:20,代码来源:BizInfo.java

示例2: parseXml2List

import org.dom4j.Element; //导入方法依赖的package包/类
/**
 * 将XML规范的字符串转为List对象(XML基于节点属性值的方式)
 * 
 * @param pStrXml 传入的符合XML格式规范的字符串
 * @return list 返回List对象
 */
public static final List parseXml2List(String pStrXml) {
    List lst = new ArrayList();
    String strTitle = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    Document document = null;
    try {
        if (pStrXml.indexOf("<?xml") < 0) pStrXml = strTitle + pStrXml;
        document = DocumentHelper.parseText(pStrXml);
    } catch (DocumentException e) {
        logger.error("==开发人员请注意:==\n将XML格式的字符串转换为XML DOM对象时发生错误啦!" + "\n详细错误信息如下:", e);
    }
    // 获取到根节点
    Element elRoot = document.getRootElement();
    // 获取根节点的所有子节点元素
    Iterator elIt = elRoot.elementIterator();
    while (elIt.hasNext()) {
        Element el = (Element)elIt.next();
        Iterator attrIt = el.attributeIterator();
        Map map = new HashMap();
        while (attrIt.hasNext()) {
            Attribute attribute = (Attribute)attrIt.next();
            map.put(attribute.getName().toLowerCase(), attribute.getData());
        }
        lst.add(map);
    }
    return lst;
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:33,代码来源:XmlUtil.java

示例3: parseXml2List

import org.dom4j.Element; //导入方法依赖的package包/类
/**
 * 将XML规范的字符串转为List对象(XML基于节点属性值的方式)
 * 
 * @param pStrXml 传入的符合XML格式规范的字符串
 * @return list 返回List对象
 */
public static final List parseXml2List(String pStrXml) {
	List lst = new ArrayList();
	String strTitle = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
	Document document = null;
	try {
		if (pStrXml.indexOf("<?xml") < 0)
			pStrXml = strTitle + pStrXml;
		document = DocumentHelper.parseText(pStrXml);
	} catch (DocumentException e) {
		log.error("==开发人员请注意:==\n将XML格式的字符串转换为XML DOM对象时发生错误啦!" + "\n详细错误信息如下:", e);
	}
	// 获取到根节点
	Element elRoot = document.getRootElement();
	// 获取根节点的所有子节点元素
	Iterator elIt = elRoot.elementIterator();
	while (elIt.hasNext()) {
		Element el = (Element) elIt.next();
		Iterator attrIt = el.attributeIterator();
		Map map = new HashMap();
		while (attrIt.hasNext()) {
			Attribute attribute = (Attribute) attrIt.next();
			map.put(attribute.getName().toLowerCase(), attribute.getData());
		}
		lst.add(map);
	}
	return lst;
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:34,代码来源:XmlUtil.java

示例4: isEmpty

import org.dom4j.Element; //导入方法依赖的package包/类
/**
 *  isEmpty returns true if neither the element, or any children recursively, have textual content or have a
 *  non-empty attribute.
 *
 * @param  e                 an Element to test
 * @param  ignoreWhiteSpace  determines whether whitespace is considered as textual content .
 * @return                   true if Element and all children recursively are empty
 */
public static boolean isEmpty(Element e, boolean ignoreWhiteSpace) {
	String t = e.getText();
	// if ((t == null) || (t.trim().length() > 0)) {

	// 02/28/07 no longer ignore whitespace!
	if (ignoreWhiteSpace && t.trim().length() > 0) {
		return false;
	}
	if (!ignoreWhiteSpace && t.length() > 0) {
		return false;
	}

	// is there a non-empty attribute? (note: we don't ignore whitespace for attributes ...)
	for (Iterator i = e.attributeIterator(); i.hasNext(); ) {
		Attribute a = (Attribute) i.next();
		String value = a.getValue();
		if ((value == null) || (value.trim().length() > 0)) {
			return false;
		}
	}

	// is there a non-empty child element?
	for (Iterator i = e.elementIterator(); i.hasNext(); ) {
		Element child = (Element) i.next();
		boolean isChildEmpty = isEmpty(child);
		if (!isChildEmpty) {
			return false;
		}
	}

	return true;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:41,代码来源:Dom4jUtils.java

示例5: getNodeExistsWithRequiredAttribute

import org.dom4j.Element; //导入方法依赖的package包/类
/**
 *  Return true if the node specified by key exists in the instance document
 *  and it has a required attribute in the instance document.
 *
 * @param  key  a jsp-encoded xpath
 * @return      The nodeExistsWithRequiredAttribute value
 */
public String getNodeExistsWithRequiredAttribute(String key) {
	String xpath = XPathUtils.decodeXPath(key);
	Node node = docMap.selectSingleNode(xpath);
	if (node == null) {
		return FALSE;
	}
	if (node.getNodeType() != Node.ELEMENT_NODE) {
		return FALSE;
	}
	Element element = (Element) node;
	if (element.attributes().isEmpty()) {
		return FALSE;
	}

	/* check attributes for a required one */
	for (Iterator i = element.attributeIterator(); i.hasNext(); ) {
		Attribute attribute = (Attribute) i.next();
		String attPath = xpath + "/@" + attribute.getQualifiedName();
		SchemaNode schemaNode = this.schemaHelper.getSchemaNode(attPath);
		if (schemaNode == null) {
			// prtln ("schemaNode not found for attribute (" + attPath + ")");
			continue;
		}
		if (schemaNode.isRequired())
			return TRUE;
	}
	return FALSE;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:36,代码来源:SchemEditForm.java

示例6: readProperties

import org.dom4j.Element; //导入方法依赖的package包/类
private List<Map<String, String>> readProperties(List<Element> propertyList) {
    List<Map<String, String>> propertyMaps=new LinkedList<>();
    for(Iterator<Element> i=propertyList.listIterator(); i.hasNext(); ){
        Element propertyElement = i.next();
        Map<String, String> propertyMap=new HashMap<>();
        for(Iterator<Attribute> j = propertyElement.attributeIterator(); j.hasNext(); ){
            Attribute attribute = j.next();
            propertyMap.put(attribute.getName(), attribute.getValue());
        }
        propertyMaps.add(propertyMap);
    }
    return propertyMaps;
}
 
开发者ID:Hang-Hu,项目名称:SimpleController,代码行数:14,代码来源:DatabaseXmlReader.java

示例7: readId

import org.dom4j.Element; //导入方法依赖的package包/类
private Map<String,String> readId(Element id) {
    Map<String, String> idMap=new HashMap<>();
    for(Iterator<Attribute> i = id.attributeIterator(); i.hasNext(); ){
        Attribute attribute= i.next();
        idMap.put(attribute.getName(), attribute.getValue());
    }
    return idMap;
}
 
开发者ID:Hang-Hu,项目名称:SimpleController,代码行数:9,代码来源:DatabaseXmlReader.java

示例8: getAttributes

import org.dom4j.Element; //导入方法依赖的package包/类
/**
 * @param xpath XPath , pointing to a XML element
 * @return a HashMap , containing the attributes and their values
 * @throws XMLException
 */
@PublicAtsApi
public Map<String, String> getAttributes(
                                          String xpath ) throws XMLException {

    if (StringUtils.isNullOrEmpty(xpath)) {

        throw new XMLException("Null/empty xpath is not allowed.");

    }

    Element element = findElement(xpath);

    if (element == null) {

        throw new XMLException("'" + xpath + "' is not a valid path");

    }

    HashMap<String, String> attributes = new HashMap<>(1);

    Iterator<Attribute> it = element.attributeIterator();

    while (it.hasNext()) {
        Attribute attr = it.next();
        attributes.put(attr.getName(), attr.getValue());
    }

    return attributes;

}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:36,代码来源:XmlText.java


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