本文整理汇总了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);
}