public final 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 |
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 byte[] |
decode(byte[] encodedBytes) |
static byte[] |
decode(String encodedString) |
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 String |
encodeToString(byte[] bytes) |
static Set<Node> |
excludeNodeFromSet(Node signatureElement,
Set<Node> inputSet) |
static byte[] |
getBytes(BigInteger big,
int bitlen)
Returns a byte-array representation of a
. |
static String |
getFullTextChildrenFromNode(Node node)
Method getFullTextChildrenFromNode
|
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 boolean |
isIgnoreLineBreaks() |
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 Document |
read(InputStream inputStream,
boolean disallowDocTypeDeclarations) |
static Element |
selectDs11Node(Node sibling,
String nodeName,
int number) |
static Element[] |
selectDs11Nodes(Node sibling,
String nodeName) |
static Element |
selectDsNode(Node sibling,
String nodeName,
int number) |
static Element[] |
selectDsNodes(Node sibling,
String nodeName) |
static Element |
selectNode(Node sibling,
String uri,
String nodeName,
int number) |
static Element[] |
selectNodes(Node sibling,
String uri,
String nodeName) |
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 namespaceSecurityException
- if a security manager is installed and the
caller does not have permission to set the prefixpublic static void setDs11Prefix(String prefix)
prefix
- the new prefix for the digital signature 1.1 namespaceSecurityException
- if a security manager is installed and the
caller does not have permission to set the prefixpublic static void setXencPrefix(String prefix)
prefix
- the new prefix for the encryption namespaceSecurityException
- if a security manager is installed and the
caller does not have permission to set the prefixpublic static void setXenc11Prefix(String prefix)
prefix
- the new prefix for the encryption namespace 1.1SecurityException
- if a security manager is installed and the
caller does not have permission to set the prefixpublic 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 OutputStream
public 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 OutputStream
addPreamble
- public static void outputDOMc14nWithComments(Node contextNode, OutputStream os)
contextNode
into the OutputStream, but
suppresses all Exceptions.
NOTE: This should only be used for debugging purposes,
NOT in a production environment; this method ignores all exceptions,
so you won't notice if something goes wrong. If you're asking what is to
be used in a production environment, simply use the code inside the
try{}
statement, but handle the Exceptions appropriately.contextNode
- os
- public static String getFullTextChildrenFromNode(Node node)
node
- 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 void addReturnToElement(Element e)
e
- public static void addReturnToElement(Document doc, HelperNodeList nl)
public static String encodeToString(byte[] bytes)
public static byte[] decode(String encodedString)
public static byte[] decode(byte[] encodedBytes)
public static boolean isIgnoreLineBreaks()
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 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 boolean protectAgainstWrappingAttack(Node startNode, String value)
public static boolean protectAgainstWrappingAttack(Node startNode, Element knownElement, String value)
public static Document read(InputStream inputStream, boolean disallowDocTypeDeclarations) throws XMLParserException
XMLParserException
public static byte[] getBytes(BigInteger big, int bitlen)
BigInteger
.
No sign-bit is output.
N.B.: BigInteger
's toByteArray
returns eventually longer arrays because of the leading sign-bit.big
- BigInteger
to be convertedbitlen
- int
the desired length in bits of the representationbitlen
bits of big
Copyright © 2000–2020 The Apache Software Foundation. All rights reserved.