當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.ATTRIBUTE_NODE屬性代碼示例

本文整理匯總了Java中org.dom4j.Node.ATTRIBUTE_NODE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Node.ATTRIBUTE_NODE屬性的具體用法?Java Node.ATTRIBUTE_NODE怎麽用?Java Node.ATTRIBUTE_NODE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.dom4j.Node的用法示例。


在下文中一共展示了Node.ATTRIBUTE_NODE屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: process

@Override
public <T> T process(T xml, Iterable<Effect> effects) throws XmlBuilderException {
    if (!canHandle(xml)) {
        throw new IllegalArgumentException("XML model is not supported");
    }
    final Node xmlNode = (Node) xml;
    final Dom4jNode<?> node;
    switch (xmlNode.getNodeType()) {
        case Node.DOCUMENT_NODE:
            node = new Dom4jDocument((Document) xmlNode);
            break;
        case Node.ELEMENT_NODE:
            node = new Dom4jElement((Element) xmlNode);
            break;
        case Node.ATTRIBUTE_NODE:
            node = new Dom4jAttribute((Attribute) xmlNode);
            break;
        default:
            throw new IllegalArgumentException("XML node type is not supported");
    }
    final Navigator<Dom4jNode> navigator = new Dom4jNavigator(xmlNode);
    for (Effect effect : effects) {
        effect.perform(navigator, node);
    }
    return xml;
}
 
開發者ID:SimY4,項目名稱:xpath-to-xml,代碼行數:26,代碼來源:Dom4jNavigatorSpi.java

示例2: isEmpty

/**
 *  Returns true if an element (recursively) has no textual content, no
 *  children, and no attributes with values.<p>
 *
 *  Note: returns FALSE if no node exists at the given path.
 *
 * @param  xpath  Description of the Parameter
 * @return        true if empty, false if any errors are encountered
 */
public boolean isEmpty(String xpath) {
	Node node = doc.selectSingleNode(xpath);
	String msg = "";

	// return FALSE if a node is not found (this is kind of a wierd convention?)
	if (node == null) {
		msg = " ... couldn't find node at " + xpath + " returning FALSE";
		// prtlnErr(msg);
		return false;
	}

	if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
		String content = node.getText();
		// return (content == null || content.trim().length() == 0);

		// 2/28/07 - no longer ignore whitespace!
		return (content == null || content.length() == 0);
	}

	if (node.getNodeType() != Node.ELEMENT_NODE) {
		msg = "  ...  called with an unknown type of node - returning false";
		// prtlnErr(msg);
		return false;
	}

	boolean ret = Dom4jUtils.isEmpty((Element) node);
	return ret;
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:37,代碼來源:DocMap.java

示例3: init

/**
 *  Description of the Method
 *
 *@param  e  Description of the Parameter
 */
private void init(Element e) {
	// prtln ("init with:\n" + e.asXML());
	if (validatingType == null) {
		// validatingType = typeDef;
		validatingType = findValidatingType(getTypeDef());
	}
	setIsChoiceMember();
	attMap = new HashMap();
	propMap = new HashMap();
	String nodeTypeString = e.getName();

	if (nodeTypeString.equals("element") || nodeTypeString.equals ("any")) {
		nodeType = Node.ELEMENT_NODE;
		
		minOccurs = SchemaHelper.getMinOccurs(e);
		maxOccurs = SchemaHelper.getMaxOccurs(e);
		// prtln ("minOccurs: " + minOccurs + "  maxOccurs: " + maxOccurs);
		
		String nillable = e.attributeValue("nillable", SchemaHelper.NILLABLE_DEFAULT);
		if ((nillable != null) && (nillable.trim().length() > 0)) {
			attMap.put("nillable", nillable);
		}

		if (e.attributeValue("fixed", null) != null) {
			readOnly = true;
		}
		
		attMap.put ("substitutionGroup", e.attributeValue("substitutionGroup", ""));
		attMap.put ("abstract", e.attributeValue("abstract", ""));
	}

	else if (nodeTypeString.equals("attribute")) {
		nodeType = Node.ATTRIBUTE_NODE;
		String use = e.attributeValue("use");
		if ((use != null) && (use.trim().length() > 0)) {
			attMap.put("use", use);
		}
	}
	else {
		nodeType = Node.UNKNOWN_NODE;
	}
	
	if (schemaDocAware)
		extractDocumentation (e);
	
	// prtln ("Instantiated SchemaNode\n" + toString());
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:52,代碼來源:SchemaNode.java

示例4: isAttribute

/**
 *  Gets the attribute attribute of the SchemaNode object
 *
 *@return    The attribute value
 */
public boolean isAttribute() {
	return (getNodeType() == Node.ATTRIBUTE_NODE);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:8,代碼來源:SchemaNode.java


注:本文中的org.dom4j.Node.ATTRIBUTE_NODE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。