Top Description Inners Fields Constructors Methods
groovy.util

public Class XmlNodePrinter

extends Object
Class Inheritance
Annotations
@Deprecated
Imports
groovy.xml.QName, org.codehaus.groovy.runtime.InvokerHelper, java.io.OutputStreamWriter, .PrintWriter, java.util.HashMap, .List, .Map

Deprecated

use groovy.xml.XmlNodePrinter

Prints a groovy.util.Node (as used with XmlParser) including all children in XML format. Typical usage:
def xml = '<html><head><title>Title</title></head><body><h1>Header</h1></body></html>'
def root = new XmlParser().parseText(xml)
new XmlNodePrinter(preserveWhitespace:true).print(root.body[0])
which when run produces this on stdout (or use your own PrintWriter to direct elsewhere):
<body>
  <h1>Header</h1>
</body>
See Also
groovy.util.NodePrinter, groovy.xml.XmlUtil#serialize(Node)

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
protected final IndentPrinter
private boolean
private String

Constructor Summary

AccessConstructor and Description
public
public
public
public
public
public

Method Summary

Modifier and TypeMethod and Description
private String
getName(Object object)

public String

Returns:

the quote character
getQuote
()

Get Quote to use when printing attributes.

private static boolean
public boolean

Returns:

true, if empty elements will be represented by an opening tag followed immediately by a closing tag.
isExpandEmptyElements
()

Whether empty elements are expanded from <tagName/> to <tagName></tagName>.

private boolean
isListOfSimple(List<E> value)

public boolean

Returns:

true if namespace handling is enabled
isNamespaceAware
()

Check if namespace handling is enabled.

public boolean

Returns:

true if whitespaces are honoured when printing simple text nodes
isPreserveWhitespace
()

Check if whitespace preservation is enabled.

private void
printEscaped(String s, boolean isAttributeValue)

protected void
protected void
protected void
protected void
printList(List<E> list, XmlNodePrinter.NamespaceContext ctx)

Deprecated as a consequence of XmlNodePrinter.NamespaceContext being deprecated.
protected void
printName(Node node, XmlNodePrinter.NamespaceContext ctx, boolean begin, boolean preserve)

Deprecated as a consequence of XmlNodePrinter.NamespaceContext being deprecated.
protected void
printNameAttributes(Map<K, V> attributes, XmlNodePrinter.NamespaceContext ctx)

Deprecated as a consequence of XmlNodePrinter.NamespaceContext being deprecated.
protected void
printNamespace(Object object, XmlNodePrinter.NamespaceContext ctx)

Deprecated as a consequence of XmlNodePrinter.NamespaceContext being deprecated.
protected void
private void
protected boolean
public void
setExpandEmptyElements(boolean
if true, empty elements will be represented by an opening tag followed immediately by a closing tag. Defaults to false.
expandEmptyElements
)

Whether empty elements are expanded from <tagName/> to <tagName></tagName>.

public void
setNamespaceAware(boolean
the new desired value
namespaceAware
)

Enable and/or disable namespace handling.

public void
setPreserveWhitespace(boolean
the new desired value
preserveWhitespace
)

Enable and/or disable preservation of whitespace.

public void
setQuote(String
the quote character
quote
)

Set Quote to use when printing attributes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

expandEmptyElementsback to summary
private boolean expandEmptyElements
namespaceAwareback to summary
private boolean namespaceAware
outback to summary
protected final IndentPrinter out
preserveWhitespaceback to summary
private boolean preserveWhitespace
quoteback to summary
private String quote

Constructor Detail

XmlNodePrinterback to summary
public XmlNodePrinter(PrintWriter out)
XmlNodePrinterback to summary
public XmlNodePrinter(PrintWriter out, String indent)
XmlNodePrinterback to summary
public XmlNodePrinter(PrintWriter out, String indent, String quote)
XmlNodePrinterback to summary
public XmlNodePrinter(IndentPrinter out)
XmlNodePrinterback to summary
public XmlNodePrinter(IndentPrinter out, String quote)
XmlNodePrinterback to summary
public XmlNodePrinter()

Method Detail

getNameback to summary
private String getName(Object object)
getQuoteback to summary
public String getQuote()

Get Quote to use when printing attributes.

Returns:String

the quote character

isEmptyElementback to summary
private static boolean isEmptyElement(Node node)
isExpandEmptyElementsback to summary
public boolean isExpandEmptyElements()

Whether empty elements are expanded from <tagName/> to <tagName></tagName>.

Returns:boolean

true, if empty elements will be represented by an opening tag followed immediately by a closing tag.

isListOfSimpleback to summary
private boolean isListOfSimple(List<E> value)
isNamespaceAwareback to summary
public boolean isNamespaceAware()

Check if namespace handling is enabled. Defaults to true.

Returns:boolean

true if namespace handling is enabled

isPreserveWhitespaceback to summary
public boolean isPreserveWhitespace()

Check if whitespace preservation is enabled. Defaults to false.

Returns:boolean

true if whitespaces are honoured when printing simple text nodes

printEscapedback to summary
private void printEscaped(String s, boolean isAttributeValue)
printLineBeginback to summary
protected void printLineBegin()
printLineEndback to summary
protected void printLineEnd()
printLineEndback to summary
protected void printLineEnd(String comment)
printListback to summary
protected void printList(List<E> list, XmlNodePrinter.NamespaceContext ctx)

Deprecated

as a consequence of XmlNodePrinter.NamespaceContext being deprecated. See corresponding docs for further information.

printNameback to summary
protected void printName(Node node, XmlNodePrinter.NamespaceContext ctx, boolean begin, boolean preserve)

Deprecated

as a consequence of XmlNodePrinter.NamespaceContext being deprecated. See corresponding docs for further information.

printNameAttributesback to summary
protected void printNameAttributes(Map<K, V> attributes, XmlNodePrinter.NamespaceContext ctx)

Deprecated

as a consequence of XmlNodePrinter.NamespaceContext being deprecated. See corresponding docs for further information.

printNamespaceback to summary
protected void printNamespace(Object object, XmlNodePrinter.NamespaceContext ctx)

Deprecated

as a consequence of XmlNodePrinter.NamespaceContext being deprecated. See corresponding docs for further information.

printSimpleItemback to summary
protected void printSimpleItem(Object value)
printSimpleItemWithIndentback to summary
private void printSimpleItemWithIndent(Object value)
printSpecialNodeback to summary
protected boolean printSpecialNode(Node node)
setExpandEmptyElementsback to summary
public void setExpandEmptyElements(boolean expandEmptyElements)

Whether empty elements are expanded from <tagName/> to <tagName></tagName>.

Parameters
expandEmptyElements:boolean

if true, empty elements will be represented by an opening tag followed immediately by a closing tag. Defaults to false.

setNamespaceAwareback to summary
public void setNamespaceAware(boolean namespaceAware)

Enable and/or disable namespace handling.

Parameters
namespaceAware:boolean

the new desired value

setPreserveWhitespaceback to summary
public void setPreserveWhitespace(boolean preserveWhitespace)

Enable and/or disable preservation of whitespace.

Parameters
preserveWhitespace:boolean

the new desired value

setQuoteback to summary
public void setQuote(String quote)

Set Quote to use when printing attributes.

Parameters
quote:String

the quote character

groovy.util back to summary

protected Class XmlNodePrinter.NamespaceContext

extends Object
Class Inheritance
Annotations
@Deprecated

Deprecated

Field Summary

Modifier and TypeField and Description
private final Map<String, String>

Constructor Summary

AccessConstructor and Description
public
public
NamespaceContext(XmlNodePrinter.NamespaceContext context)

Deprecated as a consequence of XmlNodePrinter.NamespaceContext being deprecated.

Method Summary

Modifier and TypeMethod and Description
public String
public boolean
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

namespaceMapback to summary
private final Map<String, String> namespaceMap

Constructor Detail

NamespaceContextback to summary
public NamespaceContext()
NamespaceContextback to summary
public NamespaceContext(XmlNodePrinter.NamespaceContext context)

Deprecated

as a consequence of XmlNodePrinter.NamespaceContext being deprecated. See corresponding docs for further information.

Method Detail

getNamespaceback to summary
public String getNamespace(String prefix)
isPrefixRegisteredback to summary
public boolean isPrefixRegistered(String prefix, String uri)
registerNamespacePrefixback to summary
public void registerNamespacePrefix(String prefix, String uri)