Package org.apache.xml.security.utils
Class XMLUtils
java.lang.Object
org.apache.xml.security.utils.XMLUtils
DOM and XML accessibility and comfort functions.
- Author:
- Christian Geuer-Pollmann
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Method addReturnToElementstatic void
This method spreads all namespace attributes in a DOM document to their children.static Set
convertNodelistToSet
(NodeList xpathNodeSet) Method convertNodelistToSetstatic Element
createDSctx
(Document doc, String prefix, String namespace) Method createDSctxstatic Element
createElementInSignatureSpace
(Document doc, String elementName) Creates an Element in the XML Signature specification namespace.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
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
excludeNodeFromSet
(Node signatureElement, Set inputSet) static String
getFullTextChildrenFromElement
(Element element) Method getFullTextChildrenFromElementstatic Document
getOwnerDocument
(Set xpathNodeSet) This method returns the first non-null owner document of the Node's in this Set.static Document
getOwnerDocument
(Node node) This method returns the owner document of a particular node.static void
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 anOutputStream
.static void
outputDOM
(Node contextNode, OutputStream os, boolean addPreamble) Outputs a DOM tree to anOutputStream
.static void
outputDOMc14nWithComments
(Node contextNode, OutputStream os) Serializes thecontextNode
into the OutputStream, but supresses all Exceptions.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)
-
Method Details
-
getSet
- Parameters:
rootNode
-result
-exclude
-com
- wheather comments or not
-
outputDOM
Outputs a DOM tree to anOutputStream
.- Parameters:
contextNode
- root node of the DOM treeos
- theOutputStream
-
outputDOM
Outputs a DOM tree to anOutputStream
. If an Exception is thrown during execution, it's StackTrace is output to System.out, but the Exception is not re-thrown.- Parameters:
contextNode
- root node of the DOM treeos
- theOutputStream
addPreamble
-
-
outputDOMc14nWithComments
Serializes thecontextNode
into the OutputStream, but supresses 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 thetry{}
statement, but handle the Exceptions appropriately.- Parameters:
contextNode
-os
-
-
getFullTextChildrenFromElement
Method getFullTextChildrenFromElement- Parameters:
element
-- Returns:
- the string of chi;ds
-
createElementInSignatureSpace
Creates an Element in the XML Signature specification namespace.- Parameters:
doc
- the factory DocumentelementName
- the local name of the Element- Returns:
- the Element
-
elementIsInSignatureSpace
Returns true if the element is in XML Signature namespace and the local name equals the supplied one.- Parameters:
element
-localName
-- Returns:
- true if the element is in XML Signature namespace and the local name equals the supplied one
-
elementIsInEncryptionSpace
Returns true if the element is in XML Encryption namespace and the local name equals the supplied one.- Parameters:
element
-localName
-- Returns:
- true if the element is in XML Encryption namespace and the local name equals the supplied one
-
getOwnerDocument
This method returns the owner document of a particular node. This method is necessary because it always returns aDocument
.Node.getOwnerDocument()
returnsnull
if theNode
is aDocument
.- Parameters:
node
-- Returns:
- the owner document of the node
-
getOwnerDocument
This method returns the first non-null owner document of the Node's in this Set. This method is necessary because it always returns aDocument
.Node.getOwnerDocument()
returnsnull
if theNode
is aDocument
.- Parameters:
xpathNodeSet
-- Returns:
- the owner document
-
createDSctx
Method createDSctx- Parameters:
doc
-prefix
-namespace
-- Returns:
- the element.
-
addReturnToElement
Method addReturnToElement- Parameters:
e
-
-
convertNodelistToSet
Method convertNodelistToSet- Parameters:
xpathNodeSet
-- Returns:
- the set with the nodelist
-
circumventBug2650
This method spreads all namespace attributes in a DOM document to their children. This is needed because the XML Signature XPath transform must evaluate the XPath against all nodes in the input, even against XPath namespace nodes. Through a bug in XalanJ2, the namespace nodes are not fully visible in the Xalan XPath model, so we have to do this by hand in DOM spaces so that the nodes become visible in XPath space.- Parameters:
doc
-- See Also:
-
selectDsNode
- Parameters:
sibling
-nodeName
-number
-- Returns:
- nodes with the constrain
-
selectXencNode
- Parameters:
sibling
-nodeName
-number
-- Returns:
- nodes with the constrain
-
selectDsNodeText
- Parameters:
sibling
-nodeName
-number
-- Returns:
- nodes with the constrain
-
selectNodeText
- Parameters:
sibling
-uri
-nodeName
-number
-- Returns:
- nodes with the constrain
-
selectNode
- Parameters:
sibling
-uri
-nodeName
-number
-- Returns:
- nodes with the constrain
-
selectDsNodes
- Parameters:
sibling
-nodeName
-- Returns:
- nodes with the constrain
-
selectNodes
- Parameters:
sibling
-uri
-nodeName
-- Returns:
- nodes with the constrain
-
excludeNodeFromSet
- Parameters:
signatureElement
-inputSet
-- Returns:
- nodes with the constrain
-
isDescendantOrSelf
Returns true if the descendantOrSelf is on the descendant-or-self axis of the context node.- Parameters:
ctx
-descendantOrSelf
-- Returns:
- true if the node is descendant
-