當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。