use of org.w3c.dom.NodeList in project buck by facebook.
the class XmlPrettyPrinter method visitNode.
/** Visit the given node at the given depth */
private void visitNode(int depth, Node node) {
if (node == mStartNode) {
mInRange = true;
}
if (mInRange) {
visitBeforeChildren(depth, node);
if (mOpenTagOnly && mStartNode == node) {
mInRange = false;
return;
}
}
NodeList children = node.getChildNodes();
for (int i = 0, n = children.getLength(); i < n; i++) {
Node child = children.item(i);
visitNode(depth + 1, child);
}
if (mInRange) {
visitAfterChildren(depth, node);
}
if (node == mEndNode) {
mInRange = false;
}
}
use of org.w3c.dom.NodeList in project buck by facebook.
the class PositionXmlParser method findNodeAtLineAndCol.
@Nullable
private static Node findNodeAtLineAndCol(@NonNull Node node, int line, int column) {
Position p = getPositionHelper(node, -1, -1);
if (p != null) {
if (line < p.getLine() || line == p.getLine() && column != -1 && column < p.getColumn()) {
return null;
}
Position end = p.getEnd();
if (end != null) {
if (line > end.getLine() || line == end.getLine() && column != -1 && column >= end.getColumn()) {
return null;
}
}
} else {
return null;
}
NodeList children = node.getChildNodes();
for (int i = 0, n = children.getLength(); i < n; i++) {
Node item = children.item(i);
Node match = findNodeAtLineAndCol(item, line, column);
if (match != null) {
return match;
}
}
NamedNodeMap attributes = node.getAttributes();
if (attributes != null) {
for (int i = 0, n = attributes.getLength(); i < n; i++) {
Node item = attributes.item(i);
Node match = findNodeAtLineAndCol(item, line, column);
if (match != null) {
return match;
}
}
}
return node;
}
use of org.w3c.dom.NodeList in project camel by apache.
the class XMLSecurityDataFormatTest method testAsymmetricEncryptionNoKeyValue.
@Test
public void testAsymmetricEncryptionNoKeyValue() throws Exception {
KeyStoreParameters tsParameters = new KeyStoreParameters();
tsParameters.setPassword("password");
tsParameters.setResource("sender.ts");
final XMLSecurityDataFormat xmlEncDataFormat = new XMLSecurityDataFormat();
xmlEncDataFormat.setKeyOrTrustStoreParameters(tsParameters);
xmlEncDataFormat.setXmlCipherAlgorithm(testCypherAlgorithm);
xmlEncDataFormat.setRecipientKeyAlias("recipient");
xmlEncDataFormat.setAddKeyValueForEncryptedKey(false);
context.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start").marshal(xmlEncDataFormat).to("mock:encrypted");
}
});
Document doc = xmlsecTestHelper.testEncryption(TestHelper.XML_FRAGMENT, context);
NodeList nodeList = doc.getElementsByTagNameNS("http://www.w3.org/2000/09/xmldsig#", "RSAKeyValue");
Assert.assertTrue(nodeList.getLength() == 0);
}
use of org.w3c.dom.NodeList in project XobotOS by xamarin.
the class DocumentImpl method changeDocumentToThis.
/**
* Recursively change the document of {@code node} without also changing its
* parent node. Only adoptNode() should invoke this method, otherwise nodes
* will be left in an inconsistent state.
*/
private void changeDocumentToThis(NodeImpl node) {
Map<String, UserData> userData = node.document.getUserDataMapForRead(node);
if (!userData.isEmpty()) {
getUserDataMap(node).putAll(userData);
}
node.document = this;
// change the document on all child nodes
NodeList list = node.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
changeDocumentToThis((NodeImpl) list.item(i));
}
// change the document on all attribute nodes
if (node.getNodeType() == Node.ELEMENT_NODE) {
NamedNodeMap attributes = node.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
changeDocumentToThis((AttrImpl) attributes.item(i));
}
}
}
use of org.w3c.dom.NodeList in project XobotOS by xamarin.
the class InnerNodeImpl method insertChildAt.
/**
* Inserts {@code newChild} at {@code index}. If it is already child of
* another node, it is removed from there.
*/
Node insertChildAt(Node newChild, int index) throws DOMException {
if (newChild instanceof DocumentFragment) {
NodeList toAdd = newChild.getChildNodes();
for (int i = 0; i < toAdd.getLength(); i++) {
insertChildAt(toAdd.item(i), index + i);
}
return newChild;
}
LeafNodeImpl toInsert = (LeafNodeImpl) newChild;
if (toInsert.document != null && document != null && toInsert.document != document) {
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, null);
}
if (toInsert.isParentOf(this)) {
throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, null);
}
if (toInsert.parent != null) {
int oldIndex = toInsert.index;
toInsert.parent.children.remove(oldIndex);
toInsert.parent.refreshIndices(oldIndex);
}
children.add(index, toInsert);
toInsert.parent = this;
refreshIndices(index);
return newChild;
}
Aggregations