Package com.atlassian.bamboo.upgrade
Class XpathXmlUpgrader
java.lang.Object
com.atlassian.bamboo.upgrade.XpathXmlUpgrader
Helper class to perform transformation of an XML file on nodes matching given XPath expression.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionRead an XML document from afile
.read
(InputStream input) Read an XML document from aninput
stream.static void
Read XML fromfile
, applytransformation
on nodes matchingxPathExpression
and write results back to the same file.static void
Read XML fromfile
, performing actions on each visited node matchingxPathExpression
.static Document
Iterate over elements ofdocument
, performing actions on each visited node matchingxPathExpression
.static void
Write an XML document to afile
.static void
write
(Document dom, OutputStream output) Write an XML document to anoutput
stream.
-
Constructor Details
-
XpathXmlUpgrader
public XpathXmlUpgrader()
-
-
Method Details
-
visit
Read XML fromfile
, performing actions on each visited node matchingxPathExpression
. Thevisitor
should not perform transformation on acceptednodes
, as the modifications will not be persisted.- Parameters:
file
- XML file to transformxPathExpression
- nodes to be modifiedvisitor
- action to execute on each matching node- See Also:
-
transform
Read XML fromfile
, applytransformation
on nodes matchingxPathExpression
and write results back to the same file. Note: transformation is performed in-place, i.e. node is not being replaced by a new one.- Parameters:
file
- XML file to transformxPathExpression
- nodes to be modifiedtransformation
- how to modify nodes- See Also:
-
visit
Iterate over elements ofdocument
, performing actions on each visited node matchingxPathExpression
. Thevisitor
may apply in-place transformation.- Parameters:
document
- document transformxPathExpression
- nodes to be modifiedvisitor
- action to execute on each matching node
-
read
Read an XML document from afile
.- Parameters:
inputFile
- XML file- Returns:
- Optional<Document>
-
read
Read an XML document from aninput
stream.- Parameters:
input
- input stream- Returns:
- Optional<Document>
-
write
Write an XML document to afile
.- Parameters:
dom
- documentoutputFile
- XML file
-
write
Write an XML document to anoutput
stream.- Parameters:
dom
- documentoutput
- output stream
-