public class DOMUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
appendChild(Node parent,
Node child)
Checks if child element has same owner document before
appending to the parent, and imports it to the parent's document
if necessary.
|
static Element |
createElement(Document doc,
String tag,
String nsURI,
String prefix)
Creates an element in the specified namespace, with the specified tag
and namespace prefix.
|
static String |
getAttributeValue(Element elem,
String name)
Returns the attribute value for the attribute with the specified name.
|
static Element |
getFirstChildElement(Node node)
Returns the first child element of the specified node, or null if there
is no such element.
|
static Element |
getLastChildElement(Node node)
Returns the last child element of the specified node, or null if there
is no such element.
|
static Element |
getNextSiblingElement(Node node)
Returns the next sibling element of the specified node, or null if there
is no such element.
|
static String |
getNSPrefix(XMLCryptoContext context,
String nsURI)
Returns the prefix associated with the specified namespace URI
|
static Document |
getOwnerDocument(Node node)
Returns the owner document of the specified node.
|
static String |
getSignaturePrefix(XMLCryptoContext context)
Returns the prefix associated with the XML Signature namespace URI
|
static boolean |
nodesEqual(Node thisNode,
Node otherNode)
Compares 2 nodes for equality.
|
static Set<Node> |
nodeSet(NodeList nl)
Returns a Set of
Node s, backed by the specified
NodeList . |
static boolean |
paramsEqual(AlgorithmParameterSpec spec1,
AlgorithmParameterSpec spec2) |
static void |
removeAllChildren(Node node)
Removes all children nodes from the specified node.
|
static void |
setAttribute(Element elem,
String name,
String value)
Sets an element's attribute (using DOM level 2) with the
specified value and namespace prefix.
|
static void |
setAttributeID(Element elem,
String name,
String value)
Sets an element's attribute (using DOM level 2) with the
specified value and namespace prefix AND registers the ID value with
the specified element.
|
public static Document getOwnerDocument(Node node)
node
- the nodepublic static Element createElement(Document doc, String tag, String nsURI, String prefix)
doc
- the owner documenttag
- the tagnsURI
- the namespace URIprefix
- the namespace prefixpublic static void setAttribute(Element elem, String name, String value)
elem
- the element to set the attribute onname
- the name of the attributevalue
- the attribute value. If null, no attribute is set.public static void setAttributeID(Element elem, String name, String value)
elem
- the element to set the attribute onname
- the name of the attributevalue
- the attribute value. If null, no attribute is set.public static Element getFirstChildElement(Node node)
node
- the nodeNullPointerException
- if node == null
public static Element getLastChildElement(Node node)
node
- the nodeNullPointerException
- if node == null
public static Element getNextSiblingElement(Node node)
node
- the nodeNullPointerException
- if node == null
public static String getAttributeValue(Element elem, String name)
This works around a limitation of the DOM
Element.getAttributeNode
method, which does not distinguish
between an unspecified attribute and an attribute with a value of
"" (it returns "" for both cases).
elem
- the element containing the attributename
- the name of the attributepublic static Set<Node> nodeSet(NodeList nl)
Node
s, backed by the specified
NodeList
.nl
- the NodeListpublic static String getNSPrefix(XMLCryptoContext context, String nsURI)
context
- contains the namespace mapnsURI
- the namespace URIpublic static String getSignaturePrefix(XMLCryptoContext context)
context
- contains the namespace mappublic static void removeAllChildren(Node node)
node
- the parent node whose children are to be removedpublic static boolean nodesEqual(Node thisNode, Node otherNode)
public static void appendChild(Node parent, Node child)
public static boolean paramsEqual(AlgorithmParameterSpec spec1, AlgorithmParameterSpec spec2)
Copyright © 2000-2012 The Apache Software Foundation. All Rights Reserved.