Class XmlNavigateCommand
java.lang.Object
com.streamconverter.command.AbstractStreamCommand
com.streamconverter.command.impl.xml.XmlNavigateCommand
- All Implemented Interfaces:
IStreamCommand
XML Navigate Command for applying transformations to XML data.
This command navigates through XML structures and applies transformations using rules while
preserving the overall XML structure. It identifies specific elements using TreePath
slash-delimited path expressions (e.g., product/name) and applies IRule
transformations to the text content of matching nodes.
The full XML event stream — including the XML declaration, all elements, attributes, and text
nodes — is written to the output. Only character data at nodes whose path exactly matches the
configured TreePath is transformed by the rule; all other events are passed through
unchanged.
-
Field Summary
Fields inherited from class com.streamconverter.command.AbstractStreamCommand
log -
Method Summary
Modifier and TypeMethodDescriptionstatic XmlNavigateCommandFactory method for creating an XML navigation command with TreePath and rule.voidexecute(InputStream inputStream, OutputStream outputStream) Executes the command on the provided input stream and writes the result to the output stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.streamconverter.command.IStreamCommand
commandName, withLogging, withLogging
-
Method Details
-
create
Factory method for creating an XML navigation command with TreePath and rule.- Parameters:
treePath- the TreePath to select elementsrule- the transformation rule to apply to selected elements- Returns:
- an XmlNavigateCommand that transforms the specified TreePath elements with the given rule
- Throws:
IllegalArgumentException- if treePath or rule is null
-
execute
Description copied from class:AbstractStreamCommandExecutes the command on the provided input stream and writes the result to the output stream.- Specified by:
executein interfaceIStreamCommand- Specified by:
executein classAbstractStreamCommand- Parameters:
inputStream- The input stream to read data from.outputStream- The output stream to write data to.- Throws:
IOException- If an I/O error occurs during the execution of the command.
-