org.w3c.dom.Node.getLocalName()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(1156)

本文整理了Java中org.w3c.dom.Node.getLocalName()方法的一些代码示例,展示了Node.getLocalName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getLocalName()方法的具体详情如下:
包路径:org.w3c.dom.Node
类名称:Node
方法名:getLocalName

Node.getLocalName介绍

[英]Returns the local part of the qualified name of this node.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as Document.createElement(), this is always null.
[中]返回此节点的限定名称的本地部分。
对于ELEMENT_NODEATTRIBUTE_NODE之外的任何类型的节点,以及使用DOM级别1方法创建的节点,如Document.createElement(),这始终是null

代码示例

代码示例来源:origin: spring-projects/spring-framework

  1. /**
  2. * Matches the given node's name and local name against the given desired name.
  3. */
  4. private static boolean nodeNameMatch(Node node, String desiredName) {
  5. return (desiredName.equals(node.getNodeName()) || desiredName.equals(node.getLocalName()));
  6. }

代码示例来源:origin: apache/incubator-dubbo

  1. private static void parseProperties(NodeList nodeList, RootBeanDefinition beanDefinition) {
  2. if (nodeList != null && nodeList.getLength() > 0) {
  3. for (int i = 0; i < nodeList.getLength(); i++) {
  4. Node node = nodeList.item(i);
  5. if (node instanceof Element) {
  6. if ("property".equals(node.getNodeName())
  7. || "property".equals(node.getLocalName())) {
  8. String name = ((Element) node).getAttribute("name");
  9. if (name != null && name.length() > 0) {
  10. String value = ((Element) node).getAttribute("value");
  11. String ref = ((Element) node).getAttribute("ref");
  12. if (value != null && value.length() > 0) {
  13. beanDefinition.getPropertyValues().addPropertyValue(name, value);
  14. } else if (ref != null && ref.length() > 0) {
  15. beanDefinition.getPropertyValues().addPropertyValue(name, new RuntimeBeanReference(ref));
  16. } else {
  17. throw new UnsupportedOperationException("Unsupported <property name=\"" + name + "\"> sub tag, Only supported <property name=\"" + name + "\" ref=\"...\" /> or <property name=\"" + name + "\" value=\"...\" />");
  18. }
  19. }
  20. }
  21. }
  22. }
  23. }
  24. }

代码示例来源:origin: plutext/docx4j

  1. /**
  2. * @param sibling
  3. * @param nodeName
  4. * @param number
  5. * @return nodes with the constraint
  6. */
  7. public static Element selectDsNode(Node sibling, String nodeName, int number) {
  8. while (sibling != null) {
  9. if (Constants.SignatureSpecNS.equals(sibling.getNamespaceURI())
  10. && sibling.getLocalName().equals(nodeName)) {
  11. if (number == 0){
  12. return (Element)sibling;
  13. }
  14. number--;
  15. }
  16. sibling = sibling.getNextSibling();
  17. }
  18. return null;
  19. }

代码示例来源:origin: robovm/robovm

  1. values.add(node.getNodeType());
  2. values.add(node.getNodeName());
  3. values.add(node.getLocalName());
  4. values.add(node.getNamespaceURI());
  5. values.add(node.getPrefix());
  6. values.add(node.getNodeValue());
  7. for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
  8. values.add(child);
  9. switch (node.getNodeType()) {
  10. case DOCUMENT_TYPE_NODE:
  11. DocumentTypeImpl doctype = (DocumentTypeImpl) node;

代码示例来源:origin: org.netbeans.api/org-openide-util

  1. Element result = null;
  2. NodeList l = parent.getChildNodes();
  3. int nodeCount = l.getLength();
  4. for (int i = 0; i < nodeCount; i++) {
  5. if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
  6. Node node = l.item(i);
  7. String localName = node.getLocalName();
  8. localName = localName == null ? node.getNodeName() : localName;
  9. && (namespace == null || namespace.equals(node.getNamespaceURI()))) {
  10. if (result == null) {
  11. result = (Element)node;

代码示例来源:origin: plutext/docx4j

  1. private void read(InputStream is) throws Exception {
  2. Document domDoc = XmlUtils.getNewDocumentBuilder().parse(is);
  3. Element presetShapeDefinitons = domDoc.getDocumentElement();
  4. NodeList nodes = presetShapeDefinitons.getChildNodes();
  5. for (int i = 0; i < nodes.getLength(); i++) {
  6. Node node = nodes.item(i);
  7. if (!(node instanceof Element)) continue;
  8. String name = node.getLocalName();
  9. CTCustomGeometry2D geom = (CTCustomGeometry2D)XmlUtils.unmarshal(node, Context.jc, CTCustomGeometry2D.class);
  10. if(containsKey(name)) {
  11. log.warn("Duplicate definition of " + name) ; // happened for upDownArrow; that dupe now commented out
  12. }
  13. put(name, geom);
  14. log.debug(name);
  15. }
  16. }

代码示例来源:origin: stackoverflow.com

  1. NodeList nodes = (NodeList) result;
  2. for (int i = 0; i < nodes.getLength(); i++) {
  3. Node currentItem = nodes.item(i);
  4. System.out.println("found node -> " + currentItem.getLocalName() + " (namespace: " + currentItem.getNamespaceURI() + ")");

代码示例来源:origin: robovm/robovm

  1. private boolean namedNodeMapsEqual(NamedNodeMap a, NamedNodeMap b) {
  2. if (a.getLength() != b.getLength()) {
  3. return false;
  4. }
  5. for (int i = 0; i < a.getLength(); i++) {
  6. Node aNode = a.item(i);
  7. Node bNode = aNode.getLocalName() == null
  8. ? b.getNamedItem(aNode.getNodeName())
  9. : b.getNamedItemNS(aNode.getNamespaceURI(), aNode.getLocalName());
  10. if (bNode == null || !aNode.isEqualNode(bNode)) {
  11. return false;
  12. }
  13. }
  14. return true;
  15. }

代码示例来源:origin: robovm/robovm

  1. Node p = (root.getNodeType() == Node.ATTRIBUTE_NODE) ? ((org.w3c.dom.Attr)root).getOwnerElement() : root.getParentNode();
  2. for (; p != null; p = p.getParentNode())
  3. handle=dtm.getAttributeNode(handle,node.getNamespaceURI(),node.getLocalName());

代码示例来源:origin: robovm/robovm

  1. for (int i = 0, length = attributes.getLength(); i < length; i++) {
  2. Node attr = attributes.item(i);
  3. if (!"http://www.w3.org/2000/xmlns/".equals(attr.getNamespaceURI())
  4. || !"xmlns".equals(attr.getPrefix())
  5. || !namespaceURI.equals(attr.getNodeValue())) {
  6. continue;
  7. if (target.isPrefixMappedToUri(attr.getLocalName(), namespaceURI)) {
  8. return attr.getLocalName();

代码示例来源:origin: org.freemarker/freemarker

  1. return new SimpleScalar(getText(node));
  2. } else if (key.equals(AtAtKey.NAMESPACE.getKey())) {
  3. String nsURI = node.getNamespaceURI();
  4. return nsURI == null ? null : new SimpleScalar(nsURI);
  5. } else if (key.equals(AtAtKey.LOCAL_NAME.getKey())) {
  6. String localName = node.getLocalName();
  7. if (localName == null) {
  8. localName = getNodeName();
  9. StringBuilder buf = new StringBuilder();
  10. NodeOutputter nu = new NodeOutputter(node);
  11. nu.outputContent(node.getChildNodes(), buf);
  12. return new SimpleScalar(buf.toString());
  13. } else if (key.equals(AtAtKey.QNAME.getKey())) {

代码示例来源:origin: apache/incubator-dubbo

  1. private static void parseProperties(NodeList nodeList, RootBeanDefinition beanDefinition) {
  2. if (nodeList != null && nodeList.getLength() > 0) {
  3. for (int i = 0; i < nodeList.getLength(); i++) {
  4. Node node = nodeList.item(i);
  5. if (node instanceof Element) {
  6. if ("property".equals(node.getNodeName())
  7. || "property".equals(node.getLocalName())) {
  8. String name = ((Element) node).getAttribute("name");
  9. if (name != null && name.length() > 0) {
  10. String value = ((Element) node).getAttribute("value");
  11. String ref = ((Element) node).getAttribute("ref");
  12. if (value != null && value.length() > 0) {
  13. beanDefinition.getPropertyValues().addPropertyValue(name, value);
  14. } else if (ref != null && ref.length() > 0) {
  15. beanDefinition.getPropertyValues().addPropertyValue(name, new RuntimeBeanReference(ref));
  16. } else {
  17. throw new UnsupportedOperationException("Unsupported <property name=\"" + name + "\"> sub tag, Only supported <property name=\"" + name + "\" ref=\"...\" /> or <property name=\"" + name + "\" value=\"...\" />");
  18. }
  19. }
  20. }
  21. }
  22. }
  23. }
  24. }

代码示例来源:origin: robovm/robovm

  1. for (int i = 0, length = attributes.getLength(); i < length; i++) {
  2. Node attr = attributes.item(i);
  3. if (!"http://www.w3.org/2000/xmlns/".equals(attr.getNamespaceURI())) {
  4. continue;
  5. ? "xmlns".equals(attr.getNodeName())
  6. : "xmlns".equals(attr.getPrefix()) && prefix.equals(attr.getLocalName())) {
  7. String value = attr.getNodeValue();
  8. return value.length() > 0 ? value : null;

代码示例来源:origin: fengjiachun/Jupiter

  1. private BeanDefinition parseJupiterProvider(Element element, ParserContext parserContext) {
  2. RootBeanDefinition def = new RootBeanDefinition();
  3. def.setBeanClass(beanClass);
  4. addPropertyReference(def, element, "server", true);
  5. addPropertyReference(def, element, "providerImpl", true);
  6. NodeList childNodes = element.getChildNodes();
  7. for (int i = 0; i < childNodes.getLength(); i++) {
  8. Node item = childNodes.item(i);
  9. if (item instanceof Element) {
  10. String localName = item.getLocalName();
  11. if ("property".equals(localName)) {
  12. addProperty(def, (Element) item, "weight", false);
  13. addPropertyReferenceArray(
  14. def,
  15. (Element) item,
  16. ProviderInterceptor.class.getName(),
  17. "providerInterceptors",
  18. false);
  19. addPropertyReference(def, (Element) item, "executor", false);
  20. addPropertyReference(def, (Element) item, "flowController", false);
  21. addPropertyReference(def, (Element) item, "providerInitializer", false);
  22. addPropertyReference(def, (Element) item, "providerInitializerExecutor", false);
  23. }
  24. }
  25. }
  26. return registerBean(def, element, parserContext);
  27. }

代码示例来源:origin: spring-projects/spring-framework

  1. /**
  2. * Matches the given node's name and local name against the given desired names.
  3. */
  4. private static boolean nodeNameMatch(Node node, Collection<?> desiredNames) {
  5. return (desiredNames.contains(node.getNodeName()) || desiredNames.contains(node.getLocalName()));
  6. }

代码示例来源:origin: org.freemarker/freemarker

  1. private void outputQualifiedName(Node n, StringBuilder buf) {
  2. String nsURI = n.getNamespaceURI();
  3. if (nsURI == null || nsURI.length() == 0) {
  4. buf.append(n.getNodeName());
  5. } else {
  6. String prefix = namespacesToPrefixLookup.get(nsURI);
  7. if (prefix == null) {
  8. //REVISIT!
  9. buf.append(n.getNodeName());
  10. } else {
  11. if (prefix.length() > 0) {
  12. buf.append(prefix);
  13. buf.append(':');
  14. }
  15. buf.append(n.getLocalName());
  16. }
  17. }
  18. }

代码示例来源:origin: xalan/xalan

  1. Node p = (root.getNodeType() == Node.ATTRIBUTE_NODE) ? ((org.w3c.dom.Attr)root).getOwnerElement() : root.getParentNode();
  2. for (; p != null; p = p.getParentNode())
  3. handle=dtm.getAttributeNode(handle,node.getNamespaceURI(),node.getLocalName());

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. protected void write(OutputStream out) throws IOException {
  2. XmlObject rootObject = XmlObject.Factory.newInstance();
  3. XmlCursor rootCursor = rootObject.newCursor();
  4. rootCursor.toNextToken();
  5. rootCursor.beginElement("xml");
  6. for(int i=0; i < _items.size(); i++){
  7. XmlCursor xc = _items.get(i).newCursor();
  8. rootCursor.beginElement(_qnames.get(i));
  9. while(xc.toNextToken() == XmlCursor.TokenType.ATTR) {
  10. Node anode = xc.getDomNode();
  11. rootCursor.insertAttributeWithValue(anode.getLocalName(), anode.getNamespaceURI(), anode.getNodeValue());
  12. }
  13. xc.toStartDoc();
  14. xc.copyXmlContents(rootCursor);
  15. rootCursor.toNextToken();
  16. xc.dispose();
  17. }
  18. rootCursor.dispose();
  19. rootObject.save(out, DEFAULT_XML_OPTIONS);
  20. }

代码示例来源:origin: plutext/docx4j

  1. /**
  2. * @param sibling
  3. * @param nodeName
  4. * @param number
  5. * @return nodes with the constraint
  6. */
  7. public static Element selectDs11Node(Node sibling, String nodeName, int number) {
  8. while (sibling != null) {
  9. if (Constants.SignatureSpec11NS.equals(sibling.getNamespaceURI())
  10. && sibling.getLocalName().equals(nodeName)) {
  11. if (number == 0){
  12. return (Element)sibling;
  13. }
  14. number--;
  15. }
  16. sibling = sibling.getNextSibling();
  17. }
  18. return null;
  19. }

代码示例来源:origin: apache/incubator-dubbo

  1. private static void parseNested(Element element, ParserContext parserContext, Class<?> beanClass, boolean required, String tag, String property, String ref, BeanDefinition beanDefinition) {
  2. NodeList nodeList = element.getChildNodes();
  3. if (nodeList != null && nodeList.getLength() > 0) {
  4. boolean first = true;
  5. for (int i = 0; i < nodeList.getLength(); i++) {
  6. Node node = nodeList.item(i);
  7. if (node instanceof Element) {
  8. if (tag.equals(node.getNodeName())
  9. || tag.equals(node.getLocalName())) {
  10. if (first) {
  11. first = false;
  12. String isDefault = element.getAttribute("default");
  13. if (StringUtils.isEmpty(isDefault)) {
  14. beanDefinition.getPropertyValues().addPropertyValue("default", "false");
  15. }
  16. }
  17. BeanDefinition subDefinition = parse((Element) node, parserContext, beanClass, required);
  18. if (subDefinition != null && ref != null && ref.length() > 0) {
  19. subDefinition.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(ref));
  20. }
  21. }
  22. }
  23. }
  24. }
  25. }

相关文章