本文整理了Java中org.w3c.dom.Node.getNextSibling()
方法的一些代码示例,展示了Node.getNextSibling()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getNextSibling()
方法的具体详情如下:
包路径:org.w3c.dom.Node
类名称:Node
方法名:getNextSibling
[英]The node immediately following this node. If there is no such node, this returns null
.
[中]紧跟在此节点之后的节点。如果没有这样的节点,则返回null
。
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private Element findFirstChildElement(Element parent) {
Node ret = parent.getFirstChild();
while (ret != null && (!(ret instanceof Element))) {
ret = ret.getNextSibling();
}
return (Element) ret;
}
代码示例来源:origin: plutext/docx4j
public static Element getNextElement(Node el) {
Node node = el;
while (node != null && node.getNodeType() != Node.ELEMENT_NODE) {
node = node.getNextSibling();
}
return (Element)node;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private Element findChildElement(Element parent, String name) {
if (parent == null) {
return null;
}
Node ret = parent.getFirstChild();
while (ret != null && (!(ret instanceof Element) || !ret.getNodeName().equals(name))) {
ret = ret.getNextSibling();
}
return (Element) ret;
}
代码示例来源:origin: oracle/opengrok
private String getValue(Node node) {
if (node == null) {
return null;
}
StringBuilder sb = new StringBuilder();
Node n = node.getFirstChild();
while (n != null) {
if (n.getNodeType() == Node.TEXT_NODE) {
sb.append(n.getNodeValue());
}
n = n.getNextSibling();
}
return sb.toString();
}
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
BeanDefinitionBuilder bean
) {
Node n = parent.getFirstChild();
while (n != null) {
if (Node.ELEMENT_NODE != n.getNodeType()
|| !HTTP_NS.equals(n.getNamespaceURI())) {
n = n.getNextSibling();
continue;
String elementName = n.getLocalName();
mapTLSClientParameters((Element)n, bean);
n = n.getNextSibling();
代码示例来源:origin: org.freemarker/freemarker
/**
* Recursively removes all comment nodes from the subtree.
*
* @see #simplify
*/
static public void removeComments(Node parent) {
Node child = parent.getFirstChild();
while (child != null) {
Node nextSibling = child.getNextSibling();
if (child.getNodeType() == Node.COMMENT_NODE) {
parent.removeChild(child);
} else if (child.hasChildNodes()) {
removeComments(child);
}
child = nextSibling;
}
}
代码示例来源:origin: kiegroup/jbpm
protected void readDataInputAssociation(org.w3c.dom.Node xmlNode, Map<String, String> forEachNodeInputAssociation) {
// sourceRef
org.w3c.dom.Node subNode = xmlNode.getFirstChild();
if ("sourceRef".equals(subNode.getNodeName())) {
String source = subNode.getTextContent();
// targetRef
subNode = subNode.getNextSibling();
String target = subNode.getTextContent();
forEachNodeInputAssociation.put(target, source);
}
}
代码示例来源:origin: marytts/marytts
/**
* Get the first child of <code>e</code> which is an element, or <code>null</code> if there is no such element.
*
* @param e
* e
* @return n
*/
public static Element getFirstChildElement(Element e) {
Node n = e.getFirstChild();
while (n != null && n.getNodeType() != Node.ELEMENT_NODE) {
n = n.getNextSibling();
}
// Now n is either null or an Element
return (Element) n;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
private String getComplexTypeNameFromChildren(Node localComplexTypeRootNode,
String elementNameWithoutNamespace) {
if(localComplexTypeRootNode == null) {
return "";
}
Node node = localComplexTypeRootNode.getFirstChild();
String complexTypeName = "";
while (node != null) {
if ( node instanceof Element && "element".equals(node.getLocalName())) {
Node nameAttribute = getNameOrRefElement(node);
if (nameAttribute.getNodeValue().equals(elementNameWithoutNamespace)) {
Node complexTypeAttribute = node.getAttributes().getNamedItem("type");
if (complexTypeAttribute!=null) {
complexTypeName = complexTypeAttribute.getNodeValue();
break;
}
}
}
node = node.getNextSibling();
}
return complexTypeName;
}
代码示例来源:origin: libgdx/libgdx
private void writeUpdatedTMX (TiledMap tiledMap, FileHandle tmxFileHandle) throws IOException {
Document doc;
DocumentBuilder docBuilder;
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
try {
docBuilder = docFactory.newDocumentBuilder();
doc = docBuilder.parse(tmxFileHandle.read());
Node map = doc.getFirstChild();
while (map.getNodeType() != Node.ELEMENT_NODE || map.getNodeName() != "map") {
if ((map = map.getNextSibling()) == null) {
throw new GdxRuntimeException("Couldn't find map node!");
}
}
setProperty(doc, map, "atlas", settings.tilesetOutputDirectory + "/" + settings.atlasOutputName + ".atlas");
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
outputDir.mkdirs();
StreamResult result = new StreamResult(new File(outputDir, tmxFileHandle.name()));
transformer.transform(source, result);
} catch (ParserConfigurationException e) {
throw new RuntimeException("ParserConfigurationException: " + e.getMessage());
} catch (SAXException e) {
throw new RuntimeException("SAXException: " + e.getMessage());
} catch (TransformerConfigurationException e) {
throw new RuntimeException("TransformerConfigurationException: " + e.getMessage());
} catch (TransformerException e) {
throw new RuntimeException("TransformerException: " + e.getMessage());
}
}
代码示例来源:origin: kiegroup/jbpm
protected void handleStateNode(final Node node, final Element element,
final String uri, final String localName,
final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
StateNode stateNode = (StateNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("conditionalEventDefinition".equals(nodeName)) {
org.w3c.dom.Node subNode = xmlNode.getFirstChild();
while (subNode != null) {
String subnodeName = subNode.getNodeName();
if ("condition".equals(subnodeName)) {
stateNode.setMetaData("Condition",
xmlNode.getTextContent());
break;
}
subNode = subNode.getNextSibling();
}
}
xmlNode = xmlNode.getNextSibling();
}
}
代码示例来源:origin: plantuml/plantuml
private String displayMetadata(Node node, int level) {
final NamedNodeMap map = node.getAttributes();
if (map != null) {
final Node keyword = map.getNamedItem("keyword");
if (keyword != null && tag.equals(keyword.getNodeValue())) {
final Node text = map.getNamedItem("value");
if (text != null) {
return text.getNodeValue();
}
}
}
Node child = node.getFirstChild();
// children, so close current tag
while (child != null) {
// print children recursively
final String result = displayMetadata(child, level + 1);
if (result != null) {
return result;
}
child = child.getNextSibling();
}
return null;
}
代码示例来源:origin: groovy/groovy-core
protected void printChildren(Node parent, Map namespaces) {
for (Node node = parent.getFirstChild(); node != null; node = node.getNextSibling()) {
print(node, namespaces, false);
}
}
代码示例来源:origin: loklak/loklak_server
private static JSONObject convertDOMNodeToMap(Node node) {
Node directChild = node.getFirstChild();
if (directChild == null) {
return null;
}
JSONObject result = new JSONObject(true);
while (directChild != null) {
if (directChild.getChildNodes().getLength() == 1
&& directChild.getChildNodes().item(0).getNodeType() == Node.TEXT_NODE) {
result.put(directChild.getNodeName(), directChild.getChildNodes().item(0).getTextContent());
} else {
result.put(directChild.getNodeName(), convertDOMNodeToMap(directChild));
}
directChild = directChild.getNextSibling();
}
return result;
}
代码示例来源:origin: jamesagnew/hapi-fhir
private XhtmlNode parseNode(Element node, String defaultNS) throws FHIRFormatError {
XhtmlNode res = new XhtmlNode(NodeType.Element);
res.setName(node.getLocalName());
defaultNS = checkNS(res, node, defaultNS);
for (int i = 0; i < node.getAttributes().getLength(); i++) {
Attr attr = (Attr) node.getAttributes().item(i);
if (attributeIsOk(res.getName(), attr.getName(), attr.getValue()) && !attr.getLocalName().startsWith("xmlns"))
res.getAttributes().put(attr.getName(), attr.getValue());
}
Node child = node.getFirstChild();
while (child != null) {
if (child.getNodeType() == Node.TEXT_NODE) {
res.addText(child.getTextContent());
} else if (child.getNodeType() == Node.COMMENT_NODE) {
res.addComment(child.getTextContent());
} else if (child.getNodeType() == Node.ELEMENT_NODE) {
if (elementIsOk(child.getLocalName()))
res.getChildNodes().add(parseNode((Element) child, defaultNS));
} else
throw new FHIRFormatError("Unhandled XHTML feature: "+Integer.toString(child.getNodeType())+descLoc());
child = child.getNextSibling();
}
return res;
}
代码示例来源:origin: kiegroup/jbpm
protected void handleForEachNode(final Node node, final Element element, final String uri,
final String localName, final ExtensibleXmlParser parser) throws SAXException {
ForEachNode forEachNode = (ForEachNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataInputAssociation".equals(nodeName)) {
readDataInputAssociation(xmlNode, inputAssociation);
} else if ("dataOutputAssociation".equals(nodeName)) {
readDataOutputAssociation(xmlNode, outputAssociation);
} else if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
readMultiInstanceLoopCharacteristics(xmlNode, forEachNode, parser);
}
xmlNode = xmlNode.getNextSibling();
}
}
代码示例来源:origin: org.freemarker/freemarker
/**
* Recursively removes all processing instruction nodes from the subtree.
*
* @see #simplify
*/
static public void removePIs(Node parent) {
Node child = parent.getFirstChild();
while (child != null) {
Node nextSibling = child.getNextSibling();
if (child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
parent.removeChild(child);
} else if (child.hasChildNodes()) {
removePIs(child);
}
child = nextSibling;
}
}
代码示例来源:origin: kiegroup/jbpm
protected void readDataOutputAssociation(org.w3c.dom.Node xmlNode, Map<String, String> forEachNodeOutputAssociation) {
// sourceRef
org.w3c.dom.Node subNode = xmlNode.getFirstChild();
if ("sourceRef".equals(subNode.getNodeName())) {
String source = subNode.getTextContent();
// targetRef
subNode = subNode.getNextSibling();
String target = subNode.getTextContent();
forEachNodeOutputAssociation.put(source, target);
}
}
代码示例来源:origin: marytts/marytts
/**
* Get the first child of <code>e</code> which is an element, or <code>null</code> if there is no such element.
*
* @param e
* e
* @return n
*/
public static Element getFirstChildElement(Element e) {
Node n = e.getFirstChild();
while (n != null && n.getNodeType() != Node.ELEMENT_NODE) {
n = n.getNextSibling();
}
// Now n is either null or an Element
return (Element) n;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
private Node getComplexTypeNodeFromSchemaChildren(Node xmlSchema, Node complexTypeNode,
String complexTypeName) {
Node node = xmlSchema.getFirstChild();
while (node != null) {
if ( node instanceof Element) {
if ("complexType".equals(node.getLocalName())) {
Node nameAttribute = getNameOrRefElement(node);
if (nameAttribute.getNodeValue().equals(complexTypeName)) {
Node sequence = node.getFirstChild();
while(sequence != null) {
final String localName = sequence.getLocalName();
if ("sequence".equals(localName) || "all".equals(localName)) {
complexTypeNode = sequence;
sequence = sequence.getNextSibling();
node = node.getNextSibling();
内容来源于网络,如有侵权,请联系作者删除!