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


Java Node.hasAttributes方法代码示例

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


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

示例1: parseDocument

import org.w3c.dom.Node; //导入方法依赖的package包/类
private static Flag parseDocument(Node node) throws IOException {
	String type = node.getNodeName();
	if (type.equalsIgnoreCase("#document")) {
		for (Node child : getChildren(node)) {
			String ctype = child.getNodeName();
			if (ctype.equalsIgnoreCase("flag")) {
				if (child.hasAttributes() || child.hasChildNodes()) {
					return parseFlag(child);
				}
			} else {
				throw new IOException("Unknown element: " + ctype);
			}
		}
		throw new IOException("Empty document.");
	} else {
		throw new IOException("Unknown element: " + type);
	}
}
 
开发者ID:kreativekorp,项目名称:vexillo,代码行数:19,代码来源:FlagParser.java

示例2: unevaluatedXML

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
   * return a string of unevaluated XML.      When the AIML parser
   * encounters an unrecognized XML tag, it simply passes through the
   * tag in XML form.  For example, if the response contains HTML
   * markup, the HTML is passed to the requesting process.    However if that
   * markup contains AIML tags, those tags are evaluated and the parser
   * builds the result.
   *
   * @param node           current parse node.
   * @param ps             current parse state.
   * @return               the unevaluated XML string
   */
  private static String unevaluatedXML(String resultIn, Node node, ParseState ps) {
      //MagicBooleans.trace("AIMLProcessor.unevaluatedXML(resultIn: " + resultIn + ", node: " + node + ", ps: " + ps);
      String nodeName = node.getNodeName();
      //MagicBooleans.trace("in AIMLProcessor.unevaluatedXML(), nodeName: " + nodeName);
      String attributes = "";
      if (node.hasAttributes()) {
          NamedNodeMap XMLAttributes = node.getAttributes();
          for(int i=0; i < XMLAttributes.getLength(); i++)

          {
              attributes += " "+XMLAttributes.item(i).getNodeName()+"=\""+XMLAttributes.item(i).getNodeValue()+"\"";
          }
      }
     // String contents = evalTagContent(node, ps, null);
String result = "<"+nodeName+attributes+"/>";
      if (! resultIn.equals(""))
	result = "<"+nodeName+attributes+">"+resultIn+"</"+nodeName+">";
      //MagicBooleans.trace("in AIMLProcessor.unevaluatedXML() returning: " + result);
return result;
  }
 
开发者ID:Suhas010,项目名称:Artificial-Intelligent-chat-bot-,代码行数:33,代码来源:AIMLProcessor.java

示例3: toObject

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static Object toObject(Node node) {
    if (node.getNodeType() == Node.DOCUMENT_NODE) {
        node = node.getFirstChild();
        Map<String, Object> map = new LinkedHashMap<>(1);
        map.put(node.getNodeName(), toObject(node));
        return map;
    }
    Object value = getElementAsObject(node);
    if (node.hasAttributes()) {
        Map<String, Object> wrapper = new LinkedHashMap<>(2);
        wrapper.put("_", value);
        wrapper.put("@", getAttributes(node));
        return wrapper;
    } else {
        return value;
    }
}
 
开发者ID:intuit,项目名称:karate,代码行数:18,代码来源:XmlUtils.java

示例4: traverse

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static void traverse(Node node, int depth) {
    indent(depth);
    System.out.print("<"+node.getNodeName());

    if (node.hasAttributes()) {
        NamedNodeMap attrs = node.getAttributes();
        for (int i=0; i<attrs.getLength(); i++) {
            System.out.print("  "+((Attr)attrs.item(i)).getName()+"=\""+((Attr)attrs.item(i)).getValue()+"\"");
        }
    }

    if (node.hasChildNodes()) {
        System.out.println(">");
        depth+=4;
        for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
            traverse(child, depth);
        }
        depth-=4;
        indent(depth);
        System.out.println("</"+node.getNodeName()+">");
    }
    else {
        System.out.println("/>");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:SchemaDOM.java

示例5: showMeTheDoc

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static void showMeTheDoc(Node node, int level ){
	//if (node.getNodeType()==1)
	if (node.hasAttributes()) System.out.println(node.getAttributes());
    System.out.println("Level "+level+DisplayData.multiplyChars(' ',(level-1)*10)+" Der Knoten "+node.getNodeName()
    		//+" mit dem Inhalt "+" Node Text Content: "+node.getTextContent()
    		+" und mit dem Node Type "+node.getNodeType()+" und node value: "+node.getNodeValue()
    		+" hat "+node.getChildNodes().getLength()+" Kinder "
    		);
    	if (node.hasChildNodes()){
			 NodeList children=  node.getChildNodes();
		 for (int t = 0;t<children.getLength();t++){
			showMeTheDoc(children.item(t), level+1);
		 }
	   }
}
 
开发者ID:RaduMarcel,项目名称:EspressoViews,代码行数:16,代码来源:QueryDefinitionParser.java

示例6: extractQueryDefinition

import org.w3c.dom.Node; //导入方法依赖的package包/类
private static void extractQueryDefinition(Node node, int level, Map<String,String> tagsAndContents, List<Map<String,String>> xmlExtrakt, boolean definitionBegins, String mainXmlTag) {
    //System.out.println(level+"\n Node Text Content: "+node.getTextContent());
 if (node.hasChildNodes()){
  NodeList children = node.getChildNodes();
 //System.out.println(DisplayData.multiplyChars(' ',(level-1)*10)+node.getNodeName()+" hat "+children.getLength()+" Kinder ");
 if (node.getNodeName().toUpperCase().equals(mainXmlTag) && children.getLength()>1){
	 definitionBegins=true; 
	 if (tagsAndContents.size()>0) {
		 xmlExtrakt.add(new HashMap<String,String>(tagsAndContents));
		 tagsAndContents.clear();
	 }
	 if (node.hasAttributes() ){
		 for (int t=0;t<node.getAttributes().getLength();t++ ){
			 tagsAndContents.put(node.getAttributes().item(t).getNodeName().toUpperCase(), node.getAttributes().item(t).getNodeValue().toUpperCase());
		//	 System.out.println(node.getAttributes().item(t).getNodeName()+" "+node.getAttributes().item(t).getNodeValue()); 
		 }
	 }
 }	 
 if (children.getLength()==1 && definitionBegins && !node.getNodeName().toUpperCase().equals(mainXmlTag)) {
	 //System.out.println(DisplayData.multiplyChars(' ',(level-1)*10)+"Content  "+node.getTextContent()+"\n");
	 tagsAndContents.put(node.getNodeName().toUpperCase(), node.getTextContent().trim());
 }
 for (int t = 0;t<children.getLength();t++){
	 extractQueryDefinition(children.item(t), level+1,tagsAndContents,xmlExtrakt,definitionBegins,mainXmlTag);
 }
  }
}
 
开发者ID:RaduMarcel,项目名称:EspressoViews,代码行数:28,代码来源:QueryDefinitionParser.java

示例7: unevaluatedXML

import org.w3c.dom.Node; //导入方法依赖的package包/类
private static String unevaluatedXML(String result, Node node) {
    String nodeName = node.getNodeName();
    String attributes = "";
    if (node.hasAttributes()) {
        NamedNodeMap XMLAttributes = node.getAttributes();
        for(int i=0; i < XMLAttributes.getLength(); i++)

        {
            attributes += " "+XMLAttributes.item(i).getNodeName()+"=\""+XMLAttributes.item(i).getNodeValue()+"\"";
        }
    }
    if (result.equals(""))
        return " <"+nodeName+attributes+"/> ";
    else return " <"+nodeName+attributes+">"+result+"</"+nodeName+"> ";   // add spaces
}
 
开发者ID:Suhas010,项目名称:Artificial-Intelligent-chat-bot-,代码行数:16,代码来源:JapaneseUtils.java

示例8: updateAttributeValue

import org.w3c.dom.Node; //导入方法依赖的package包/类
private void updateAttributeValue(Node node, String attName,
        int decimalPlacesSetting) {
    if (node.hasAttributes()
            && !"NumberOfOccurrence".equals(node.getNodeName())
            && !"ParameterValue".equals(node.getNodeName())) {
        Node attribute = node.getAttributes().getNamedItem(attName);
        if (attribute != null) {
            String priceValue = attribute.getNodeValue();
            if (priceValue != null && priceValue.length() > 0) {
                attribute.setNodeValue(getConvertedPrice(priceValue,
                        decimalPlacesSetting));
            }
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:16,代码来源:MigrationBillingResultDecimalPlace.java

示例9: hasAttributes

import org.w3c.dom.Node; //导入方法依赖的package包/类
public boolean hasAttributes(final String szPath)
{
	ensureRoot();
	Node oNode = getNodeHelper(szPath, false, false);
	if( oNode == null )
	{
		return false;
	}
	return oNode.hasAttributes();
}
 
开发者ID:equella,项目名称:Equella,代码行数:11,代码来源:PropBagEx.java

示例10: wantAlpha

import org.w3c.dom.Node; //导入方法依赖的package包/类
private boolean wantAlpha(Node transparency) {
    boolean returnValue = false;
    Node alpha = transparency.getFirstChild();  // Alpha must be first if present
    if (alpha.getNodeName().equals("Alpha")) {
        if (alpha.hasAttributes()) {
            String value =
                alpha.getAttributes().getNamedItem("value").getNodeValue();
            if (!value.equals("none")) {
                returnValue = true;
            }
        }
    }
    transparencyDone = true;
    return returnValue;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:JPEGMetadata.java

示例11: getExtensionFactoryClass

import org.w3c.dom.Node; //导入方法依赖的package包/类
private String getExtensionFactoryClass(IFile pluginXML) {
	try {
		IPath location = pluginXML.getLocation();
		if (location != null) {
			File file = location.toFile();

			DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
			Document doc = dBuilder.parse(file);

			if (doc.hasChildNodes()) {
				NodeList nodeList = doc.getChildNodes();
				for (int count = 0; count < nodeList.getLength(); count++) {
					Node tempNode = nodeList.item(count);
					if (tempNode.getNodeType() == Node.ELEMENT_NODE) {
						if (tempNode.getNodeName().equals("plugin")) {
							for (int count1 = 0; count1 < tempNode.getChildNodes().getLength(); count1++) {
								Node tempNode1 = tempNode.getChildNodes().item(count1);
								if (tempNode1.getNodeType() == Node.ELEMENT_NODE) {
									if (tempNode1.getNodeName().equals("extension")) {
										for (int count11 = 0; count11 < tempNode1.getChildNodes()
												.getLength(); count11++) {
											Node tempNode11 = tempNode1.getChildNodes().item(count11);
											if (tempNode11.getNodeType() == Node.ELEMENT_NODE) {
												if (tempNode11.getNodeName().equals("factory")) {
													if (tempNode11.hasAttributes()) {
														NamedNodeMap nodeMap = tempNode11.getAttributes();
														for (int i = 0; i < nodeMap.getLength(); i++) {
															Node node = nodeMap.item(i);
															if (node.getNodeName().equals("class")) {
																String[] args = node.getNodeValue().split("\\.");
																return args[args.length - 1];
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	return "";
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:52,代码来源:RegenerateConnectorAction.java

示例12: AIMLToCategories

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * convert an AIML file to a list of categories.
 *
 * @param directory     directory containing the AIML file.
 * @param aimlFile      AIML file name.
 * @return              list of categories.
 */
public static ArrayList<Category> AIMLToCategories (String directory, String aimlFile) {
    try {
        ArrayList categories = new ArrayList<Category>();
        Node root = DomUtils.parseFile(directory+"/"+aimlFile);      // <aiml> tag
        String language = MagicStrings.default_language;
        if (root.hasAttributes()) {
            NamedNodeMap XMLAttributes = root.getAttributes();
            for(int i=0; i < XMLAttributes.getLength(); i++)
            {
                if (XMLAttributes.item(i).getNodeName().equals("language")) language = XMLAttributes.item(i).getNodeValue();
            }
        }
        NodeList nodelist = root.getChildNodes();
        for (int i = 0; i < nodelist.getLength(); i++)   {
            Node n = nodelist.item(i);
            //System.out.println("AIML child: " +n.getNodeName());
            if (n.getNodeName().equals("category")) {
                categoryProcessor(n, categories, "*", aimlFile, language);
            }
            else if (n.getNodeName().equals("topic")) {
                String topic = n.getAttributes().getNamedItem("name").getTextContent();
	//System.out.println("topic: " + topic);
                NodeList children = n.getChildNodes();
                for (int j = 0; j < children.getLength(); j++) {
                    Node m = children.item(j);
                    //System.out.println("Topic child: " + m.getNodeName());
                    if (m.getNodeName().equals("category")) {
                        categoryProcessor(m, categories, topic, aimlFile, language);
                    }
                }
            }
        }
        return categories;
    }
    catch (Exception ex) {
        System.out.println("AIMLToCategories: "+ex);
        ex.printStackTrace();
        return null;
    }
}
 
开发者ID:Suhas010,项目名称:Artificial-Intelligent-chat-bot-,代码行数:48,代码来源:AIMLProcessor.java

示例13: addNodeInTree

import org.w3c.dom.Node; //导入方法依赖的package包/类
private void addNodeInTree(Node node, Document document, Element parent) {
    Element currentElement = createElement(document, node);
    currentElement.setAttribute("type", Short.toString(node.getNodeType()));

    switch (node.getNodeType()) {
        case Node.ELEMENT_NODE:
            currentElement.setAttribute("text", node.getNodeName());
            NamedNodeMap map = node.getAttributes();
            if (node.hasAttributes()) {
                Element attributes = createElement(document, node, false);
                attributes.setAttribute("text", "Attributes");
                attributes.setAttribute("type", Short.toString(Node.ATTRIBUTE_NODE));
                currentElement.appendChild(attributes);

                for (int i = 0; i < map.getLength(); ++i) {
                    Element attribute = createElement(document, map.item(i));
                    attribute.setAttribute("text", map.item(i).getNodeName() + "=\"" + map.item(i).getNodeValue() + "\"");
                    attribute.setAttribute("type", Short.toString(Node.ATTRIBUTE_NODE));
                    attributes.appendChild(attribute);
                }
            }
            break;

        case Node.TEXT_NODE:
            currentElement.setAttribute("text", node.getNodeValue() == null ? "" : node.getNodeValue().trim());
            break;

        case Node.ENTITY_NODE:
            currentElement.setAttribute("text", "[Entity]");
            break;

        case Node.ENTITY_REFERENCE_NODE:
            currentElement.setAttribute("text", "[Entityref]");
            break;

        case Node.PROCESSING_INSTRUCTION_NODE:
            currentElement.setAttribute("text", "[Pi]");
            break;

        case Node.COMMENT_NODE:
            currentElement.setAttribute("text", "[Comment]");
            break;

        case Node.DOCUMENT_FRAGMENT_NODE:
            currentElement.setAttribute("text", "[Docfgmt]");
            break;

        case Node.DOCUMENT_TYPE_NODE:
            currentElement.setAttribute("text", "[Doctype]");
            break;

        case Node.NOTATION_NODE:
            currentElement.setAttribute("text", "[Notation]");
            break;

        default:
            break;
    }
    parent.appendChild(currentElement);

    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node currentNode = nodeList.item(i);
        addNodeInTree(currentNode, document, currentElement);
    }
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:67,代码来源:TwsDomTreeWrap.java

示例14: addNodeInTree2

import org.w3c.dom.Node; //导入方法依赖的package包/类
private static void addNodeInTree2(Node node, Document document, Element parent, int [] index) {
    Element currentElement = createElement2(document, node, index);
    currentElement.setAttribute("type", Short.toString(node.getNodeType()));

    switch (node.getNodeType()) {
        case Node.ELEMENT_NODE:
            currentElement.setAttribute("text", node.getNodeName());
            NamedNodeMap map = node.getAttributes();
            if (node.hasAttributes()) {
                Element attributes = createElement2(document, node, index);
                attributes.setAttribute("text", "Attributes");
                attributes.setAttribute("type", Short.toString(Node.ATTRIBUTE_NODE));
                currentElement.appendChild(attributes);

                for (int i = 0; i < map.getLength(); ++i) {
                    Element attribute = createElement2(document, map.item(i), index);
                    attribute.setAttribute("text", map.item(i).getNodeName() + "=\"" + map.item(i).getNodeValue() + "\"");
                    attribute.setAttribute("type", Short.toString(Node.ATTRIBUTE_NODE));
                    attributes.appendChild(attribute);
                }
            }
            break;

        case Node.TEXT_NODE:
            currentElement.setAttribute("text", node.getNodeValue() == null ? "" : node.getNodeValue().trim());
            break;

        case Node.ENTITY_NODE:
            currentElement.setAttribute("text", "[Entity]");
            break;

        case Node.ENTITY_REFERENCE_NODE:
            currentElement.setAttribute("text", "[Entityref]");
            break;

        case Node.PROCESSING_INSTRUCTION_NODE:
            currentElement.setAttribute("text", "[Pi]");
            break;

        case Node.COMMENT_NODE:
            currentElement.setAttribute("text", "[Comment]");
            break;

        case Node.DOCUMENT_FRAGMENT_NODE:
            currentElement.setAttribute("text", "[Docfgmt]");
            break;

        case Node.DOCUMENT_TYPE_NODE:
            currentElement.setAttribute("text", "[Doctype]");
            break;

        case Node.NOTATION_NODE:
            currentElement.setAttribute("text", "[Notation]");
            break;

        default:
            break;
    }
    parent.appendChild(currentElement);

    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node currentNode = nodeList.item(i);
        addNodeInTree2(currentNode, document, currentElement, index);
    }
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:67,代码来源:TwsDomTreeWrap.java

示例15: getExtensionScheme

import org.w3c.dom.Node; //导入方法依赖的package包/类
private String getExtensionScheme(IFile pluginXML) {
	try {
		IPath location = pluginXML.getLocation();
		if (location != null) {
			File file = location.toFile();

			DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
			Document doc = dBuilder.parse(file);

			if (doc.hasChildNodes()) {
				NodeList nodeList = doc.getChildNodes();
				for (int count = 0; count < nodeList.getLength(); count++) {
					Node tempNode = nodeList.item(count);
					if (tempNode.getNodeType() == Node.ELEMENT_NODE) {
						if (tempNode.getNodeName().equals("plugin")) {
							for (int count1 = 0; count1 < tempNode.getChildNodes().getLength(); count1++) {
								Node tempNode1 = tempNode.getChildNodes().item(count1);
								if (tempNode1.getNodeType() == Node.ELEMENT_NODE) {
									if (tempNode1.getNodeName().equals("extension")) {
										for (int count11 = 0; count11 < tempNode1.getChildNodes()
												.getLength(); count11++) {
											Node tempNode11 = tempNode1.getChildNodes().item(count11);
											if (tempNode11.getNodeType() == Node.ELEMENT_NODE) {
												if (tempNode11.getNodeName().equals("factory")) {
													if (tempNode11.hasAttributes()) {
														NamedNodeMap nodeMap = tempNode11.getAttributes();
														for (int i = 0; i < nodeMap.getLength(); i++) {
															Node node = nodeMap.item(i);
															if (node.getNodeName().equals("uri")) {
																return node.getNodeValue()
																		.substring(0,
																				node.getNodeValue().length()
																						- ("/ecore".length()))
																		.concat("#");
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	return "";
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:55,代码来源:RegenerateConnectorAction.java


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