本文整理匯總了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;
}
示例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;
}
示例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());
}
示例4: isAttribute
/**
* Gets the attribute attribute of the SchemaNode object
*
*@return The attribute value
*/
public boolean isAttribute() {
return (getNodeType() == Node.ATTRIBUTE_NODE);
}