Example usage for org.w3c.dom Node setPrefix

List of usage examples for org.w3c.dom Node setPrefix

Introduction

In this page you can find the example usage for org.w3c.dom Node setPrefix.

Prototype

public void setPrefix(String prefix) throws DOMException;

Source Link

Document

The namespace prefix of this node, or null if it is unspecified.

Usage

From source file:Main.java

private static void setPrefixRecursively(Node node, String prefix) {
    node.setPrefix(prefix);
    for (int i = 0; i < node.getChildNodes().getLength(); i++) {
        setPrefixRecursively(node.getChildNodes().item(i), prefix);
    }/* ww w.j ava2 s.c o  m*/
}

From source file:Main.java

public static void setPrefixRecursive(final Node node, final String prefix) {

    if (node.getNodeType() == Node.ELEMENT_NODE) {
        node.setPrefix(prefix);
    }//from   w w w.  j  a v  a  2  s  . c  o  m

    final NodeList list = node.getChildNodes();
    for (int i = 0; i < list.getLength(); ++i) {
        setPrefixRecursive(list.item(i), prefix);
    }
}

From source file:org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties.java

protected void replacePrefixForNode(Node node, Input input) {
    if (XMLSignature.XMLNS.equals(node.getNamespaceURI())) {
        node.setPrefix(input.getPrefixForXmlSignatureNamespace());
    } else if (findNamespace(input.getMessage()).equals(node.getNamespaceURI())) {
        node.setPrefix(findPrefix(input.getMessage()));
    }/*from   w w w. j  ava2s. c o  m*/
}

From source file:org.ojbc.bundles.adapters.staticmock.StaticMockQuery.java

private Document createFirearmRegistrationDocument(Document document, String firearmId) throws Exception {
    Document copy = createNewDocument();
    copy.appendChild(copy.importNode(document.getDocumentElement(), true));
    Node rootElement = XmlUtils.xPathNodeSearch(copy, "/*");
    LOG.debug("Keeper: " + firearmId);
    NodeList otherFirearmNodes = XmlUtils.xPathNodeListSearch(rootElement,
            "firearm-ext:Firearm[@s:id != '" + firearmId + "']");
    for (int i = 0; i < otherFirearmNodes.getLength(); i++) {
        Node goner = otherFirearmNodes.item(i);
        LOG.debug("Goner: " + XmlUtils.xPathStringSearch(goner, "@s:id"));
        rootElement.removeChild(goner);//from  www.j  av  a2  s .  co  m
    }
    NodeList otherItemRegNodes = XmlUtils.xPathNodeListSearch(rootElement,
            "firearm-ext:ItemRegistration[@s:id != /firearm-doc:PersonFirearmRegistrationQueryResults/nc:PropertyRegistrationAssociation[nc:ItemReference/@s:ref='"
                    + firearmId + "']/nc:ItemRegistrationReference/@s:ref]");
    for (int i = 0; i < otherItemRegNodes.getLength(); i++) {
        rootElement.removeChild(otherItemRegNodes.item(i));
    }
    NodeList otherRegAssociationNodes = XmlUtils.xPathNodeListSearch(rootElement,
            "nc:PropertyRegistrationAssociation[nc:ItemReference/@s:ref != '" + firearmId + "']");
    for (int i = 0; i < otherRegAssociationNodes.getLength(); i++) {
        rootElement.removeChild(otherRegAssociationNodes.item(i));
    }
    copy.renameNode(rootElement, rootElement.getNamespaceURI(), "FirearmRegistrationQueryResults");
    Node documentRootElement = XmlUtils.xPathNodeSearch(document, "/*");
    rootElement.setPrefix(documentRootElement.getPrefix());
    return copy;
}