java.lang.Object | |
↳ | org.apache.xml.serialize.OutputFormat |
This class is deprecated.
This class was deprecated in Xerces 2.9.0. It is recommended
that new applications use the DOM Level 3 LSSerializer or JAXP's Transformation
API for XML (TrAX) for serializing XML and HTML. See the Xerces documentation for
more information.
Specifies an output format to control the serializer. Based on the XSLT specification for output format, plus additional parameters. Used to select the suitable serializer and determine how the document should be formatted on output.
The two interesting constructors are:
OutputFormat(String, String, boolean)
creates a format
for the specified method (XML, HTML, Text, etc), encoding and indentation
OutputFormat(Document, String, boolean)
creates a format
compatible with the document type (XML, HTML, Text, etc), encoding and
indentation
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
OutputFormat.DTD | This class is deprecated. This class was deprecated in Xerces 2.9.0. It is recommended that new applications use the DOM Level 3 LSSerializer or JAXP's Transformation API for XML (TrAX) for serializing XML and HTML. See the Xerces documentation for more information. | ||||||||||
OutputFormat.Defaults | This class is deprecated. This class was deprecated in Xerces 2.9.0. It is recommended that new applications use the DOM Level 3 LSSerializer or JAXP's Transformation API for XML (TrAX) for serializing XML and HTML. See the Xerces documentation for more information. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new output format with the default values.
| |||||||||||
Constructs a new output format with the default values for
the specified method and encoding.
| |||||||||||
Constructs a new output format with the proper method,
document type identifiers and media type for the specified
document.
| |||||||||||
Constructs a new output format with the proper method,
document type identifiers and media type for the specified
document, and with the specified encoding.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a list of all the elements whose text node children
should be output as CDATA, or null if no such elements were
specified.
| |||||||||||
Returns the specified document type public identifier,
or null.
| |||||||||||
Returns the specified document type system identifier,
or null.
| |||||||||||
Returns the specified encoding.
| |||||||||||
Returns an
EncodingInfo instance for the encoding. | |||||||||||
Returns the indentation specified.
| |||||||||||
Returns true if indentation was specified.
| |||||||||||
Returns the last printable character based on the selected
encoding.
| |||||||||||
Returns a specific line separator to use.
| |||||||||||
Return the selected line width for breaking up long lines.
| |||||||||||
Returns the specified media type, or null.
| |||||||||||
Returns the method specified for this output format.
| |||||||||||
Returns a list of all the elements whose text node children
should be output unescaped (no character references), or null
if no such elements were specified.
| |||||||||||
Returns true if comments should be ommited.
| |||||||||||
Returns true if the DOCTYPE declaration should
be ommited.
| |||||||||||
Returns true if the XML document declaration should
be ommited.
| |||||||||||
Returns the preserveEmptyAttribute flag.
| |||||||||||
Returns true if the default behavior for this format is to
preserve spaces.
| |||||||||||
Returns true if the document type is standalone.
| |||||||||||
Returns the version for this output method.
| |||||||||||
Returns true if the text node children of the given elements
should be output as CDATA.
| |||||||||||
Returns true if the text node children of the given elements
should be output unescaped.
| |||||||||||
Sets whether java encoding names are permitted
| |||||||||||
Returns whether java encoding names are permitted
| |||||||||||
Sets the list of elements for which text node children
should be output as CDATA.
| |||||||||||
Sets the document type public and system identifiers.
| |||||||||||
Sets the encoding for this output method.
| |||||||||||
Sets the encoding for this output method with an
EncodingInfo
instance. | |||||||||||
Sets the indentation.
| |||||||||||
Sets the indentation on and off.
| |||||||||||
Sets the line separator.
| |||||||||||
Sets the line width.
| |||||||||||
Sets the media type.
| |||||||||||
Sets the method for this output format.
| |||||||||||
Sets the list of elements for which text node children
should be output unescaped (no character references).
| |||||||||||
Sets comment omitting on and off.
| |||||||||||
Sets DOCTYPE declaration omitting on and off.
| |||||||||||
Sets XML declaration omitting on and off.
| |||||||||||
Sets the preserveEmptyAttribute flag.
| |||||||||||
Sets space preserving as the default behavior.
| |||||||||||
Sets document DTD standalone.
| |||||||||||
Sets the version for this output method.
| |||||||||||
Returns the document type public identifier
specified for this document, or null.
| |||||||||||
Returns the document type system identifier
specified for this document, or null.
| |||||||||||
Returns the suitable media format for a document
output with the specified method.
| |||||||||||
Determine the output method for the specified document.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Constructs a new output format with the default values.
Constructs a new output format with the default values for the specified method and encoding. If indent is true, the document will be pretty printed with the default indentation level and default line wrapping.
method | The specified output method |
---|---|
encoding | The specified encoding |
indenting | True for pretty printing |
Constructs a new output format with the proper method, document type identifiers and media type for the specified document.
doc | The document to output |
---|
Constructs a new output format with the proper method, document type identifiers and media type for the specified document, and with the specified encoding. If indent is true, the document will be pretty printed with the default indentation level and default line wrapping.
doc | The document to output |
---|---|
encoding | The specified encoding |
indenting | True for pretty printing |
Returns a list of all the elements whose text node children should be output as CDATA, or null if no such elements were specified.
Returns the specified encoding. If no encoding was specified, the default is always "UTF-8".
Returns the indentation specified. If no indentation was specified, zero is returned and the document should not be indented.
Returns true if indentation was specified.
Returns the last printable character based on the selected encoding. Control characters and non-printable characters are always printed as character references.
Returns a specific line separator to use. The default is the Web line separator (\n). A string is returned to support double codes (CR + LF).
Return the selected line width for breaking up long lines. When indenting, and only when indenting, long lines will be broken at space boundaries based on this line width. No line wrapping occurs if this value is zero.
Returns the specified media type, or null.
To determine the media type based on the
document type, use whichMediaType(String)
.
Returns the method specified for this output format.
Typically the method will be xml, html
or text, but it might be other values.
If no method was specified, null will be returned
and the most suitable method will be determined for
the document by calling whichMethod(Document)
.
Returns a list of all the elements whose text node children should be output unescaped (no character references), or null if no such elements were specified.
Returns true if comments should be ommited. The default is false.
Returns true if the DOCTYPE declaration should be ommited. The default is false.
Returns true if the XML document declaration should be ommited. The default is false.
Returns the preserveEmptyAttribute flag. If flag is false, then' attributes with empty string values are output as the attribute name only (in HTML mode).
Returns true if the default behavior for this format is to preserve spaces. All elements that do not specify otherwise or specify the default behavior will be formatted based on this rule. All elements that specify space preserving will always preserve space.
Returns true if the document type is standalone. The default is false.
Returns the version for this output method. If no version was specified, will return null and the default version number will be used. If the serializer does not support that particular version, it should default to a supported version.
Returns true if the text node children of the given elements should be output as CDATA.
tagName | The element's tag name |
---|
Returns true if the text node children of the given elements should be output unescaped.
tagName | The element's tag name |
---|
Sets whether java encoding names are permitted
Returns whether java encoding names are permitted
Sets the list of elements for which text node children should be output as CDATA.
cdataElements | List of CDATA element tag names |
---|
Sets the document type public and system identifiers. Required only if the DOM Document or SAX events do not specify the document type, and one must be present in the serialized document. Any document type specified by the DOM Document or SAX events will override these values.
publicId | The public identifier, or null |
---|---|
systemId | The system identifier, or null |
Sets the encoding for this output method. If no
encoding was specified, the default is always "UTF-8".
Make sure the encoding is compatible with the one
used by the Writer
.
encoding | The encoding, or null |
---|
Sets the encoding for this output method with an EncodingInfo
instance.
Sets the indentation. The document will not be
indented if the indentation is set to zero.
Calling setIndenting(boolean)
will reset this
value to zero (off) or the default (on).
indent | The indentation, or zero |
---|
Sets the indentation on and off. When set on, the default
indentation level and default line wrapping is used
(see Indent
and LineWidth
).
To specify a different indentation level or line wrapping,
use setIndent(int)
and setLineWidth(int)
.
on | True if indentation should be on |
---|
Sets the line separator. The default is the Web line separator (\n). The machine's line separator can be obtained from the system property line.separator, but is only useful if the document is edited on machines of the same type. For general documents, use the Web line separator.
lineSeparator | The specified line separator |
---|
Sets the line width. If zero then no line wrapping will
occur. Calling setIndenting(boolean)
will reset this
value to zero (off) or the default (on).
lineWidth | The line width to use, zero for default |
---|
Sets the method for this output format.
method | The output method, or null |
---|
Sets the list of elements for which text node children should be output unescaped (no character references).
nonEscapingElements | List of unescaped element tag names |
---|
Sets comment omitting on and off.
omit | True if comments should be ommited |
---|
Sets DOCTYPE declaration omitting on and off.
omit | True if DOCTYPE declaration should be ommited |
---|
Sets XML declaration omitting on and off.
omit | True if XML declaration should be ommited |
---|
Sets the preserveEmptyAttribute flag. If flag is false, then' attributes with empty string values are output as the attribute name only (in HTML mode).
preserve | the preserve flag |
---|
Sets space preserving as the default behavior. The default is space stripping and all elements that do not specify otherwise or use the default value will not preserve spaces.
preserve | True if spaces should be preserved |
---|
Sets document DTD standalone. The public and system identifiers must be null for the document to be serialized as standalone.
standalone | True if document DTD is standalone |
---|
Sets the version for this output method. For XML the value would be "1.0", for HTML it would be "4.0".
version | The output method version, or null |
---|
Returns the document type public identifier specified for this document, or null.
Returns the document type system identifier specified for this document, or null.
Returns the suitable media format for a document output with the specified method.
Determine the output method for the specified document. If the document is an instance of org.w3c.dom.html.HTMLDocument then the method is said to be html. If the root element is 'html' and all text nodes preceding the root element are all whitespace, then the method is said to be html. Otherwise the method is xml.
doc | The document to check |
---|