Class XmlTreeRenderer
- java.lang.Object
-
- net.sourceforge.pmd.util.treeexport.XmlTreeRenderer
-
- All Implemented Interfaces:
TreeRenderer
@Experimental public final class XmlTreeRenderer extends Object implements TreeRenderer
Renders a tree to XML. The resulting document is as close as possible to the representation PMD uses to run XPath queries on nodes. This allows the same XPath queries to match, in theory (it would depend on the XPath engine used I believe).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
XmlTreeRenderer.XmlRenderingConfig
A strategy to parameterize anXmlTreeRenderer
.
-
Constructor Summary
Constructors Constructor Description XmlTreeRenderer()
Creates a new XML renderer with a default configuration.XmlTreeRenderer(XmlTreeRenderer.XmlRenderingConfig strategy)
Creates a new XML renderer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
renderSubtree(Node node, Appendable out)
Appends the subtree rooted at the given node on the provided output writer.
-
-
-
Constructor Detail
-
XmlTreeRenderer
public XmlTreeRenderer(XmlTreeRenderer.XmlRenderingConfig strategy)
Creates a new XML renderer.- Parameters:
strategy
- Strategy to parameterize the output of this instance
-
XmlTreeRenderer
public XmlTreeRenderer()
Creates a new XML renderer with a default configuration.
-
-
Method Detail
-
renderSubtree
public void renderSubtree(Node node, Appendable out) throws IOException
Appends the subtree rooted at the given node on the provided output writer. The implementation is free to filter out some nodes from the subtree.Each node of the AST has a corresponding XML element, whose name and attributes are the one the node presents in XPath queries.
- Specified by:
renderSubtree
in interfaceTreeRenderer
- Parameters:
node
- Node to renderout
- Object onto which the output is appended- Throws:
IllegalArgumentException
- If some node has attributes or a name that is not a valid XML nameIOException
- If an IO error occurs while appending to the output
-
-