public class XMLUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
addReturnBeforeChild(Element e,
Node child) |
static void |
addReturnToElement(Document doc,
HelperNodeList nl) |
static void |
addReturnToElement(Element e)
Method addReturnToElement
|
static void |
circumventBug2650(Document doc)
This method spreads all namespace attributes in a DOM document to their
children.
|
static Set<Node> |
convertNodelistToSet(NodeList xpathNodeSet)
Method convertNodelistToSet
|
static Element |
createDSctx(Document doc,
String prefix,
String namespace)
Method createDSctx
|
static Element |
createElementInEncryption11Space(Document doc,
String elementName)
Creates an Element in the XML Encryption 1.1 specification namespace.
|
static Element |
createElementInEncryptionSpace(Document doc,
String elementName)
Creates an Element in the XML Encryption specification namespace.
|
static Element |
createElementInSignature11Space(Document doc,
String elementName)
Creates an Element in the XML Signature 1.1 specification namespace.
|
static Element |
createElementInSignatureSpace(Document doc,
String elementName)
Creates an Element in the XML Signature specification namespace.
|
static boolean |
elementIsInEncryption11Space(Element element,
String localName)
Returns true if the element is in XML Encryption 1.1 namespace and the local
name equals the supplied one.
|
static boolean |
elementIsInEncryptionSpace(Element element,
String localName)
Returns true if the element is in XML Encryption namespace and the local
name equals the supplied one.
|
static boolean |
elementIsInSignature11Space(Element element,
String localName)
Returns true if the element is in XML Signature 1.1 namespace and the local
name equals the supplied one.
|
static boolean |
elementIsInSignatureSpace(Element element,
String localName)
Returns true if the element is in XML Signature namespace and the local
name equals the supplied one.
|
static Set<Node> |
excludeNodeFromSet(Node signatureElement,
Set<Node> inputSet) |
static String |
getAttributeValue(Element elem,
String name)
Returns the attribute value for the attribute with the specified name.
|
static String |
getFullTextChildrenFromElement(Element element)
Method getFullTextChildrenFromElement
|
static Element |
getNextElement(Node el) |
static Document |
getOwnerDocument(Node node)
This method returns the owner document of a particular node.
|
static Document |
getOwnerDocument(Set<Node> xpathNodeSet)
This method returns the first non-null owner document of the Nodes in this Set.
|
static void |
getSet(Node rootNode,
Set<Node> result,
Node exclude,
boolean com) |
static String |
getStrFromNode(Node xpathnode)
Method getStrFromNode
|
static boolean |
ignoreLineBreaks() |
static boolean |
isDescendantOrSelf(Node ctx,
Node descendantOrSelf)
Returns true if the descendantOrSelf is on the descendant-or-self axis
of the context node.
|
static void |
outputDOM(Node contextNode,
OutputStream os)
Outputs a DOM tree to an
OutputStream. |
static void |
outputDOM(Node contextNode,
OutputStream os,
boolean addPreamble)
Outputs a DOM tree to an
OutputStream. |
static void |
outputDOMc14nWithComments(Node contextNode,
OutputStream os)
Serializes the
contextNode into the OutputStream, but
suppresses all Exceptions. |
static boolean |
protectAgainstWrappingAttack(Node startNode,
Element knownElement,
String value)
This method is a tree-search to help prevent against wrapping attacks.
|
static boolean |
protectAgainstWrappingAttack(Node startNode,
String value)
This method is a tree-search to help prevent against wrapping attacks.
|
static Element |
selectDs11Node(Node sibling,
String nodeName,
int number) |
static Element[] |
selectDs11Nodes(Node sibling,
String nodeName) |
static Text |
selectDs11NodeText(Node sibling,
String nodeName,
int number) |
static Element |
selectDsNode(Node sibling,
String nodeName,
int number) |
static Element[] |
selectDsNodes(Node sibling,
String nodeName) |
static Text |
selectDsNodeText(Node sibling,
String nodeName,
int number) |
static Element |
selectNode(Node sibling,
String uri,
String nodeName,
int number) |
static Element[] |
selectNodes(Node sibling,
String uri,
String nodeName) |
static Text |
selectNodeText(Node sibling,
String uri,
String nodeName,
int number) |
static Element |
selectXencNode(Node sibling,
String nodeName,
int number) |
static void |
setDs11Prefix(String prefix)
Set the prefix for the digital signature 1.1 namespace
|
static void |
setDsPrefix(String prefix)
Set the prefix for the digital signature namespace
|
static void |
setXenc11Prefix(String prefix)
Set the prefix for the encryption namespace 1.1
|
static void |
setXencPrefix(String prefix)
Set the prefix for the encryption namespace
|
public static void setDsPrefix(String prefix)
prefix - the new prefix for the digital signature namespacepublic static void setDs11Prefix(String prefix)
prefix - the new prefix for the digital signature 1.1 namespacepublic static void setXencPrefix(String prefix)
prefix - the new prefix for the encryption namespacepublic static void setXenc11Prefix(String prefix)
prefix - the new prefix for the encryption namespace 1.1public static void getSet(Node rootNode, Set<Node> result, Node exclude, boolean com)
rootNode - result - exclude - com - whether comments or notpublic static void outputDOM(Node contextNode, OutputStream os)
OutputStream.contextNode - root node of the DOM treeos - the OutputStreampublic static void outputDOM(Node contextNode, OutputStream os, boolean addPreamble)
OutputStream. If an Exception is
thrown during execution, it's StackTrace is output to System.out, but the
Exception is not re-thrown.contextNode - root node of the DOM treeos - the OutputStreamaddPreamble - public static void outputDOMc14nWithComments(Node contextNode, OutputStream os)
contextNode into the OutputStream, but
suppresses all Exceptions.
try{} statement, but handle the Exceptions appropriately.contextNode - os - public static String getFullTextChildrenFromElement(Element element)
element - public static Element createElementInSignatureSpace(Document doc, String elementName)
doc - the factory DocumentelementName - the local name of the Elementpublic static Element createElementInSignature11Space(Document doc, String elementName)
doc - the factory DocumentelementName - the local name of the Elementpublic static Element createElementInEncryptionSpace(Document doc, String elementName)
doc - the factory DocumentelementName - the local name of the Elementpublic static Element createElementInEncryption11Space(Document doc, String elementName)
doc - the factory DocumentelementName - the local name of the Elementpublic static boolean elementIsInSignatureSpace(Element element, String localName)
element - localName - public static boolean elementIsInSignature11Space(Element element, String localName)
element - localName - public static boolean elementIsInEncryptionSpace(Element element, String localName)
element - localName - public static boolean elementIsInEncryption11Space(Element element, String localName)
element - localName - public static Document getOwnerDocument(Node node)
Document. Node.getOwnerDocument() returns null
if the Node is a Document.node - public static Document getOwnerDocument(Set<Node> xpathNodeSet)
Document. Node.getOwnerDocument() returns null
if the Node is a Document.xpathNodeSet - public static Element createDSctx(Document doc, String prefix, String namespace)
doc - prefix - namespace - public static void addReturnToElement(Element e)
e - public static void addReturnToElement(Document doc, HelperNodeList nl)
public static Set<Node> convertNodelistToSet(NodeList xpathNodeSet)
xpathNodeSet - public static void circumventBug2650(Document doc)
doc - public static Element selectDsNode(Node sibling, String nodeName, int number)
sibling - nodeName - number - public static Element selectDs11Node(Node sibling, String nodeName, int number)
sibling - nodeName - number - public static Element selectXencNode(Node sibling, String nodeName, int number)
sibling - nodeName - number - public static Text selectDsNodeText(Node sibling, String nodeName, int number)
sibling - nodeName - number - public static Text selectDs11NodeText(Node sibling, String nodeName, int number)
sibling - nodeName - number - public static Text selectNodeText(Node sibling, String uri, String nodeName, int number)
sibling - uri - nodeName - number - public static Element selectNode(Node sibling, String uri, String nodeName, int number)
sibling - uri - nodeName - number - public static Element[] selectDsNodes(Node sibling, String nodeName)
sibling - nodeName - public static Element[] selectDs11Nodes(Node sibling, String nodeName)
sibling - nodeName - public static Element[] selectNodes(Node sibling, String uri, String nodeName)
sibling - uri - nodeName - public static Set<Node> excludeNodeFromSet(Node signatureElement, Set<Node> inputSet)
signatureElement - inputSet - public static String getStrFromNode(Node xpathnode)
xpathnode - public static boolean isDescendantOrSelf(Node ctx, Node descendantOrSelf)
ctx - descendantOrSelf - public static boolean ignoreLineBreaks()
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 boolean protectAgainstWrappingAttack(Node startNode, String value)
public static boolean protectAgainstWrappingAttack(Node startNode, Element knownElement, String value)
Copyright © 2000-2013 The Apache Software Foundation. All Rights Reserved.