com.icl.saxon.trax.serialize
Class OutputFormat

java.lang.Object
  |
  +--com.icl.saxon.trax.serialize.OutputFormat

public class OutputFormat
extends java.lang.Object

The output format affects the manner in which a document is serialized. The output format determines the output method, encoding, indentation, document type, and various other properties that affect the manner in which a document is serialized.

Once an output format has been handed to a serializer or XSLT processor, the application should not attempt to reuse it. The serializer or XSLT processor may modify the properties of the output format object.

Implementations may provide classes that extend OutputFormat with additional properties, e.g. indentation level, line separation, namespace handlers, etc. An application may use these extra properties by constructing an output format object based on the implementation specified type.

OutputFormat has been modeled after the XSLT <xsl:output> element declaration. However, it does not assume the existence of an XSLT processor or a particular serializer.

Typical usage scenarios supported by OutputFormat:

See Also:
Method

Constructor Summary
OutputFormat()
          Constructs a new output format with the default values.
 
Method Summary
 QName[] getCDataElements()
          Returns a list of all the elements whose text node children should be output as CDATA.
 java.lang.String getDoctypePublicId()
          Returns the specified document type public identifier, or null.
 java.lang.String getDoctypeSystemId()
          Returns the specified document type system identifier, or null.
 java.lang.String getEncoding()
          Returns the specified encoding.
 boolean getIndent()
          Returns true if indentation was specified.
 java.lang.String getMediaType()
          Returns the specified media type.
 java.lang.String getMethod()
          Returns the method specified for this output format.
 QName[] getNonEscapingElements()
          Returns a list of all the elements whose text node children should be output unescaped (no character references).
 boolean getOmitXMLDeclaration()
          Returns true if the XML document declaration should be ommited.
 boolean getPreserveSpace()
          Returns true if the default behavior for this format is to preserve spaces.
 java.lang.String getVersion()
          Returns the version for this output method.
 void setCDataElements(QName[] cdataElements)
          Sets the list of elements for which text node children should be output as CDATA.
 void setDoctypePublicId(java.lang.String publicId)
          Sets the document type public identifiers.
 void setDoctypeSystemId(java.lang.String systemId)
          Sets the document type system identifiers.
 void setEncoding(java.lang.String encoding)
          Sets the encoding for this output method.
 void setIndenting(boolean indent)
          Sets the indentation on and off.
 void setMediaType(java.lang.String mediaType)
          Sets the media type.
 void setMethod(java.lang.String method)
          Sets the method for this output format.
 void setNonEscapingElements(QName[] nonEscapingElements)
          Sets the list of elements for which text node children should be output unescaped (no character references).
 void setOmitXMLDeclaration(boolean omit)
          Sets XML declaration omitting on and off.
 void setPreserveSpace(boolean preserve)
          Sets space preserving as the default behavior.
 void setVersion(java.lang.String version)
          Sets the version for this output method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputFormat

public OutputFormat()
Constructs a new output format with the default values.
Method Detail

getMethod

public java.lang.String getMethod()
Returns the method specified for this output format. See Method for a list of the default methods. Other methods should be of the format namespace:local. The default is Method.XML.
Returns:
The specified output method

setMethod

public void setMethod(java.lang.String method)
Sets the method for this output format. See Method for a list of the default methods. Other methods should be of the format namespace:local.
Parameters:
method - The output method, or null

getVersion

public java.lang.String getVersion()
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:
The specified method version, or null

setVersion

public void setVersion(java.lang.String version)
Sets the version for this output method.
Parameters:
version - The output method version, or null

getIndent

public boolean getIndent()
Returns true if indentation was specified. If no indentation was specified, returns false. A derived class may support additional properties, e.g. indentation level, line width to wrap at, tab/spaces, etc.
Returns:
True if indentation was specified

setIndenting

public void setIndenting(boolean indent)
Sets the indentation on and off. A derived class may support additional properties, e.g. indentation level, line width to wrap at, tab/spaces, etc. A serializer need not support indentation.
Parameters:
ident - True specifies identiation

getEncoding

public java.lang.String getEncoding()
Returns the specified encoding. If no encoding was specified, the default is used. For XML and HTML the default would be "UTF-8". For other output methods, the default encoding is unspecified.
Returns:
The encoding

setEncoding

public void setEncoding(java.lang.String encoding)
Sets the encoding for this output method. Null means the default encoding for the selected output method. For XML and HTML the default would be "UTF-8". For other output methods, the default encoding is unspecified.
Parameters:
encoding - The encoding, or null

getMediaType

public java.lang.String getMediaType()
Returns the specified media type. For each output method a default media type will be used if one was not specified.
Returns:
The specified media type, or null

setMediaType

public void setMediaType(java.lang.String mediaType)
Sets the media type. For each output method a default media type will be used if one was not specified.
Parameters:
mediaType - The specified media type

setDoctypePublicId

public void setDoctypePublicId(java.lang.String publicId)
Sets the document type public identifiers. If not specified the document type will depend on the output method (e.g. HTML, XHTML) or from some other mechanism (e.g. SAX events, DOM DocumentType).
Parameters:
publicId - The public identifier

getDoctypePublicId

public java.lang.String getDoctypePublicId()
Returns the specified document type public identifier, or null.

setDoctypeSystemId

public void setDoctypeSystemId(java.lang.String systemId)
Sets the document type system identifiers. If not specified the document type will depend on the output method (e.g. HTML, XHTML) or from some other mechanism (e.g. SAX events, DOM DocumentType).
Parameters:
systemId - The system identifier

getDoctypeSystemId

public java.lang.String getDoctypeSystemId()
Returns the specified document type system identifier, or null.

getOmitXMLDeclaration

public boolean getOmitXMLDeclaration()
Returns true if the XML document declaration should be ommited. The default is false.

setOmitXMLDeclaration

public void setOmitXMLDeclaration(boolean omit)
Sets XML declaration omitting on and off.
Parameters:
omit - True if XML declaration should be ommited

getCDataElements

public QName[] getCDataElements()
Returns a list of all the elements whose text node children should be output as CDATA. Returns an empty array if no such elements were specified.
Returns:
List of all CDATA elements

setCDataElements

public void setCDataElements(QName[] cdataElements)
Sets the list of elements for which text node children should be output as CDATA.
Parameters:
cdataElements - List of all CDATA elements

getNonEscapingElements

public QName[] getNonEscapingElements()
Returns a list of all the elements whose text node children should be output unescaped (no character references). Returns an empty array if no such elements were specified.
Returns:
List of all non escaping elements

setNonEscapingElements

public void setNonEscapingElements(QName[] nonEscapingElements)
Sets the list of elements for which text node children should be output unescaped (no character references).
Parameters:
nonEscapingElements - List of all non-escaping elements

getPreserveSpace

public boolean getPreserveSpace()
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.

setPreserveSpace

public void setPreserveSpace(boolean preserve)
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.
Parameters:
preserve - True if spaces should be preserved