本文整理了Java中org.w3c.dom.Node.getLocalName()
方法的一些代码示例,展示了Node.getLocalName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getLocalName()
方法的具体详情如下:
包路径:org.w3c.dom.Node
类名称: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_NODE
和ATTRIBUTE_NODE
之外的任何类型的节点,以及使用DOM级别1方法创建的节点,如Document.createElement()
,这始终是null
。
代码示例来源:origin: spring-projects/spring-framework
/**
* Matches the given node's name and local name against the given desired name.
*/
private static boolean nodeNameMatch(Node node, String desiredName) {
return (desiredName.equals(node.getNodeName()) || desiredName.equals(node.getLocalName()));
}
代码示例来源:origin: apache/incubator-dubbo
private static void parseProperties(NodeList nodeList, RootBeanDefinition beanDefinition) {
if (nodeList != null && nodeList.getLength() > 0) {
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node instanceof Element) {
if ("property".equals(node.getNodeName())
|| "property".equals(node.getLocalName())) {
String name = ((Element) node).getAttribute("name");
if (name != null && name.length() > 0) {
String value = ((Element) node).getAttribute("value");
String ref = ((Element) node).getAttribute("ref");
if (value != null && value.length() > 0) {
beanDefinition.getPropertyValues().addPropertyValue(name, value);
} else if (ref != null && ref.length() > 0) {
beanDefinition.getPropertyValues().addPropertyValue(name, new RuntimeBeanReference(ref));
} else {
throw new UnsupportedOperationException("Unsupported <property name=\"" + name + "\"> sub tag, Only supported <property name=\"" + name + "\" ref=\"...\" /> or <property name=\"" + name + "\" value=\"...\" />");
}
}
}
}
}
}
}
代码示例来源:origin: plutext/docx4j
/**
* @param sibling
* @param nodeName
* @param number
* @return nodes with the constraint
*/
public static Element selectDsNode(Node sibling, String nodeName, int number) {
while (sibling != null) {
if (Constants.SignatureSpecNS.equals(sibling.getNamespaceURI())
&& sibling.getLocalName().equals(nodeName)) {
if (number == 0){
return (Element)sibling;
}
number--;
}
sibling = sibling.getNextSibling();
}
return null;
}
代码示例来源:origin: robovm/robovm
values.add(node.getNodeType());
values.add(node.getNodeName());
values.add(node.getLocalName());
values.add(node.getNamespaceURI());
values.add(node.getPrefix());
values.add(node.getNodeValue());
for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
values.add(child);
switch (node.getNodeType()) {
case DOCUMENT_TYPE_NODE:
DocumentTypeImpl doctype = (DocumentTypeImpl) node;
代码示例来源:origin: org.netbeans.api/org-openide-util
Element result = null;
NodeList l = parent.getChildNodes();
int nodeCount = l.getLength();
for (int i = 0; i < nodeCount; i++) {
if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
Node node = l.item(i);
String localName = node.getLocalName();
localName = localName == null ? node.getNodeName() : localName;
&& (namespace == null || namespace.equals(node.getNamespaceURI()))) {
if (result == null) {
result = (Element)node;
代码示例来源:origin: plutext/docx4j
private void read(InputStream is) throws Exception {
Document domDoc = XmlUtils.getNewDocumentBuilder().parse(is);
Element presetShapeDefinitons = domDoc.getDocumentElement();
NodeList nodes = presetShapeDefinitons.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (!(node instanceof Element)) continue;
String name = node.getLocalName();
CTCustomGeometry2D geom = (CTCustomGeometry2D)XmlUtils.unmarshal(node, Context.jc, CTCustomGeometry2D.class);
if(containsKey(name)) {
log.warn("Duplicate definition of " + name) ; // happened for upDownArrow; that dupe now commented out
}
put(name, geom);
log.debug(name);
}
}
代码示例来源:origin: stackoverflow.com
NodeList nodes = (NodeList) result;
for (int i = 0; i < nodes.getLength(); i++) {
Node currentItem = nodes.item(i);
System.out.println("found node -> " + currentItem.getLocalName() + " (namespace: " + currentItem.getNamespaceURI() + ")");
代码示例来源:origin: robovm/robovm
private boolean namedNodeMapsEqual(NamedNodeMap a, NamedNodeMap b) {
if (a.getLength() != b.getLength()) {
return false;
}
for (int i = 0; i < a.getLength(); i++) {
Node aNode = a.item(i);
Node bNode = aNode.getLocalName() == null
? b.getNamedItem(aNode.getNodeName())
: b.getNamedItemNS(aNode.getNamespaceURI(), aNode.getLocalName());
if (bNode == null || !aNode.isEqualNode(bNode)) {
return false;
}
}
return true;
}
代码示例来源:origin: robovm/robovm
Node p = (root.getNodeType() == Node.ATTRIBUTE_NODE) ? ((org.w3c.dom.Attr)root).getOwnerElement() : root.getParentNode();
for (; p != null; p = p.getParentNode())
handle=dtm.getAttributeNode(handle,node.getNamespaceURI(),node.getLocalName());
代码示例来源:origin: robovm/robovm
for (int i = 0, length = attributes.getLength(); i < length; i++) {
Node attr = attributes.item(i);
if (!"http://www.w3.org/2000/xmlns/".equals(attr.getNamespaceURI())
|| !"xmlns".equals(attr.getPrefix())
|| !namespaceURI.equals(attr.getNodeValue())) {
continue;
if (target.isPrefixMappedToUri(attr.getLocalName(), namespaceURI)) {
return attr.getLocalName();
代码示例来源:origin: org.freemarker/freemarker
return new SimpleScalar(getText(node));
} else if (key.equals(AtAtKey.NAMESPACE.getKey())) {
String nsURI = node.getNamespaceURI();
return nsURI == null ? null : new SimpleScalar(nsURI);
} else if (key.equals(AtAtKey.LOCAL_NAME.getKey())) {
String localName = node.getLocalName();
if (localName == null) {
localName = getNodeName();
StringBuilder buf = new StringBuilder();
NodeOutputter nu = new NodeOutputter(node);
nu.outputContent(node.getChildNodes(), buf);
return new SimpleScalar(buf.toString());
} else if (key.equals(AtAtKey.QNAME.getKey())) {
代码示例来源:origin: apache/incubator-dubbo
private static void parseProperties(NodeList nodeList, RootBeanDefinition beanDefinition) {
if (nodeList != null && nodeList.getLength() > 0) {
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node instanceof Element) {
if ("property".equals(node.getNodeName())
|| "property".equals(node.getLocalName())) {
String name = ((Element) node).getAttribute("name");
if (name != null && name.length() > 0) {
String value = ((Element) node).getAttribute("value");
String ref = ((Element) node).getAttribute("ref");
if (value != null && value.length() > 0) {
beanDefinition.getPropertyValues().addPropertyValue(name, value);
} else if (ref != null && ref.length() > 0) {
beanDefinition.getPropertyValues().addPropertyValue(name, new RuntimeBeanReference(ref));
} else {
throw new UnsupportedOperationException("Unsupported <property name=\"" + name + "\"> sub tag, Only supported <property name=\"" + name + "\" ref=\"...\" /> or <property name=\"" + name + "\" value=\"...\" />");
}
}
}
}
}
}
}
代码示例来源:origin: robovm/robovm
for (int i = 0, length = attributes.getLength(); i < length; i++) {
Node attr = attributes.item(i);
if (!"http://www.w3.org/2000/xmlns/".equals(attr.getNamespaceURI())) {
continue;
? "xmlns".equals(attr.getNodeName())
: "xmlns".equals(attr.getPrefix()) && prefix.equals(attr.getLocalName())) {
String value = attr.getNodeValue();
return value.length() > 0 ? value : null;
代码示例来源:origin: fengjiachun/Jupiter
private BeanDefinition parseJupiterProvider(Element element, ParserContext parserContext) {
RootBeanDefinition def = new RootBeanDefinition();
def.setBeanClass(beanClass);
addPropertyReference(def, element, "server", true);
addPropertyReference(def, element, "providerImpl", true);
NodeList childNodes = element.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node item = childNodes.item(i);
if (item instanceof Element) {
String localName = item.getLocalName();
if ("property".equals(localName)) {
addProperty(def, (Element) item, "weight", false);
addPropertyReferenceArray(
def,
(Element) item,
ProviderInterceptor.class.getName(),
"providerInterceptors",
false);
addPropertyReference(def, (Element) item, "executor", false);
addPropertyReference(def, (Element) item, "flowController", false);
addPropertyReference(def, (Element) item, "providerInitializer", false);
addPropertyReference(def, (Element) item, "providerInitializerExecutor", false);
}
}
}
return registerBean(def, element, parserContext);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Matches the given node's name and local name against the given desired names.
*/
private static boolean nodeNameMatch(Node node, Collection<?> desiredNames) {
return (desiredNames.contains(node.getNodeName()) || desiredNames.contains(node.getLocalName()));
}
代码示例来源:origin: org.freemarker/freemarker
private void outputQualifiedName(Node n, StringBuilder buf) {
String nsURI = n.getNamespaceURI();
if (nsURI == null || nsURI.length() == 0) {
buf.append(n.getNodeName());
} else {
String prefix = namespacesToPrefixLookup.get(nsURI);
if (prefix == null) {
//REVISIT!
buf.append(n.getNodeName());
} else {
if (prefix.length() > 0) {
buf.append(prefix);
buf.append(':');
}
buf.append(n.getLocalName());
}
}
}
代码示例来源:origin: xalan/xalan
Node p = (root.getNodeType() == Node.ATTRIBUTE_NODE) ? ((org.w3c.dom.Attr)root).getOwnerElement() : root.getParentNode();
for (; p != null; p = p.getParentNode())
handle=dtm.getAttributeNode(handle,node.getNamespaceURI(),node.getLocalName());
代码示例来源:origin: org.apache.poi/poi-ooxml
protected void write(OutputStream out) throws IOException {
XmlObject rootObject = XmlObject.Factory.newInstance();
XmlCursor rootCursor = rootObject.newCursor();
rootCursor.toNextToken();
rootCursor.beginElement("xml");
for(int i=0; i < _items.size(); i++){
XmlCursor xc = _items.get(i).newCursor();
rootCursor.beginElement(_qnames.get(i));
while(xc.toNextToken() == XmlCursor.TokenType.ATTR) {
Node anode = xc.getDomNode();
rootCursor.insertAttributeWithValue(anode.getLocalName(), anode.getNamespaceURI(), anode.getNodeValue());
}
xc.toStartDoc();
xc.copyXmlContents(rootCursor);
rootCursor.toNextToken();
xc.dispose();
}
rootCursor.dispose();
rootObject.save(out, DEFAULT_XML_OPTIONS);
}
代码示例来源:origin: plutext/docx4j
/**
* @param sibling
* @param nodeName
* @param number
* @return nodes with the constraint
*/
public static Element selectDs11Node(Node sibling, String nodeName, int number) {
while (sibling != null) {
if (Constants.SignatureSpec11NS.equals(sibling.getNamespaceURI())
&& sibling.getLocalName().equals(nodeName)) {
if (number == 0){
return (Element)sibling;
}
number--;
}
sibling = sibling.getNextSibling();
}
return null;
}
代码示例来源:origin: apache/incubator-dubbo
private static void parseNested(Element element, ParserContext parserContext, Class<?> beanClass, boolean required, String tag, String property, String ref, BeanDefinition beanDefinition) {
NodeList nodeList = element.getChildNodes();
if (nodeList != null && nodeList.getLength() > 0) {
boolean first = true;
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node instanceof Element) {
if (tag.equals(node.getNodeName())
|| tag.equals(node.getLocalName())) {
if (first) {
first = false;
String isDefault = element.getAttribute("default");
if (StringUtils.isEmpty(isDefault)) {
beanDefinition.getPropertyValues().addPropertyValue("default", "false");
}
}
BeanDefinition subDefinition = parse((Element) node, parserContext, beanClass, required);
if (subDefinition != null && ref != null && ref.length() > 0) {
subDefinition.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(ref));
}
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!