org.ceryle.xml
Class XMLSerializer

java.lang.Object
  extended by org.ceryle.xml.XMLSerializer
All Implemented Interfaces:
Constants

Deprecated.

public class XMLSerializer
extends Object
implements Constants

Generates a serialization (ie., a text representation) of a DOM 2 Document object, generic XML, XTM, XHTML, HTML or plain text content. This is deliberately a simple serializer that does not handle all DOM node types, does not process DTDs, namespaces, etc. It does produce simple, well-formed XML, can correctly process XHTML (including preformatted text), and handles ignoreable whitespace correctly.

Note 1: be sure to call close() at the end of a writing process, otherwise you may end up with an empty output document.

Note 2: this class is gradually being phased out in favour of using the Xerces XMLSerializer, XHTMLSerializer, etc. New code should not be written using this XML serializer; it is now deprecated.

Since:
JDK1.3
Version:
$Id: XMLSerializer.java,v 3.11 2007-06-15 12:10:29 altheim Exp $
Author:
Murray Altheim

Field Summary
 boolean addXMLDecl
          Deprecated. Variable controlling whether XML comments should be preceded by a XML Declaration if they don't already have on (default false).
 String blockXHTML
          Deprecated. A space-delimited list of a subset of XHTML elements considered as block elements.
static int DOCTYPE_SHML_2
          Deprecated. Used by getDoctypeDeclaration() to indicate the SHML 2.0 DTD.
static int DOCTYPE_XHTML_FRAMESET
          Deprecated. Used by getDoctypeDeclaration() to indicate the XHTML 1.0 Frameset DTD.
static int DOCTYPE_XHTML_STRICT
          Deprecated. Used by getDoctypeDeclaration() to indicate the XHTML 1.0 Strict DTD.
static int DOCTYPE_XHTML_TRANSITIONAL
          Deprecated. Used by getDoctypeDeclaration() to indicate the XHTML 1.0 Transitional DTD.
 String emptyXHTML
          Deprecated. A space-delimited list of XHTML elements declared EMPTY.
 String emptyXTM
          Deprecated. A space-delimited list of XTM elements declared EMPTY.
static String encoding
          Deprecated. The String used as the content of the XML declaration's encoding attribute.
 boolean expandCommentWS
          Deprecated. Variable controlling whether XML comments should be preceded by a newline (default false).
 String inlineXHTML
          Deprecated. A space-delimited list of XHTML elements considered (by the HTML 4 Recommendation) as inline.
protected  boolean m_closeOnComplete
          Deprecated. Variable controlling whether to close the writer upon completion.
 boolean prettyPrint
          Deprecated. Variable controlling whether to include whitespace indenting.
static String SHML_DTD_PubId
          Deprecated. A String containing the Formal Public Identifier (FPI) for the SHML 2.0 DTD.
static String SHML_DTD_SysId
          Deprecated. A String containing a system identifier for the SHML 2.0 DTD.
static String XMLNS_shml
          Deprecated. The URI indicating the SHML 2.0 XML namespace.
static String XMLSPACE_ATTR
          Deprecated. The XML attribute 'xml:space'.
static String XMLSPACE_DEFAULT
          Deprecated. The value 'default' for the XML 'xml:space' attribute.
static String XMLSPACE_PRESERVE
          Deprecated. The value 'preserve' for the XML 'xml:space' attribute.
 
Fields inherited from interface org.ceryle.util.Constants
Amp, AMP, Apos, APOS, APP_NAME, APP_VERSION_NAME, APP_VERSION_NUMBER, AT, BANG, BAR, BIT_dev, BIT_http, BIT_ignoreCom, BIT_merge, BIT_none, BIT_noPreload, BIT_simple, BIT_ui, BIT_unused1, BIT_unused2, BIT_unused3, BIT_validating, BIT_verbose, BIT_xcatalog, BIT_xlink, BIT_xmlnsAware, BIT_xsd, BROKB, BSlash, BSLASH, CERYLE_CREDITS_FILE, CERYLE_DATA_DIR, CERYLE_HIST_FILE, CERYLE_LICENSE_FILE, CERYLE_PREF_FILE, CERYLE_PROP, CERYLE_PROP_BASE, CERYLE_PROP_FILE, CERYLE_RSRC_DIR, CERYLE_THANKS_FILE, CFLEX, Colon, COLON, Comma, COMMA, CR, CRet, Dash, DASH, DEFAULT_DIRECTORY, DEVELOPER, DOLR, Dot, DOT, EIGHT, Ellip, EOF, EqQuot, EQUAL, Equals, False, FALSE, FileProt, Filesep, FileURL, Five, FIVE, FONTSIZES, Four, FOUR, FSchar, GCOL_PROP, GRAPH_PROP, GRAVE, GT, Hash, HASH, HOME_DIRECTORY, HOME_DIRECTORY_PATH, HOME_DIRECTORY_URL, HTML, HttpProt, HttpURL, INDENT, INDENT_0, INDENT_1, INDENT_10, INDENT_2, INDENT_3, INDENT_4, INDENT_5, INDENT_6, INDENT_7, INDENT_8, INDENT_9, INIT, LCURL, LCurly, LF, LFS, Localhost, LPAR, LParen, LS, LSBrkt, LSBrkt2, LSQB, LT, MT, NBSP, NEL, NINE, NL, NL20x, NLchar, No, Null, NULL, NULL_STATE, NumParams, One, ONE, Pathsep, Percent, PERO, PLUS, Prcnt, PS, QMark, QMARK, Quot, QUOT, RCURL, RCurly, RESOURCE_BUNDLE, RPAR, RParen, RSBrkt, RSBrkt2, RSQB, Semi, SEMI, SEVEN, SIX, Slash, SLASH, SP, SPACE, Stago, Star, STAR, Tab, TAB, Tee, Three, THREE, Tilde, TILDE, TM_PROP, True, TRUE, Two, TWO, Under, UNDER, URI, URL, VBar, WIKI_PROP, XNodePfx, XNodeURL, XtmExt, Yes, Zero, ZERO
 
Constructor Summary
XMLSerializer(Writer out)
          Deprecated.  
XMLSerializer(Writer out, int method)
          Deprecated.  
 
Method Summary
 void close()
          Deprecated. Close the output stream.
static String getDoctypeDeclaration(int type)
          Deprecated.  
static String getSerializedNode(Node node)
          Deprecated.  
 void serializeDocument(Node node)
          Deprecated. Output a DOM Node (such as a Document) to the output stream, closing the writer when complete.
 void serializeElementContent(Element element)
          Deprecated. Output an Element Node to the output stream, closing the writer when complete.
static String serializeNode(MessageHandler mh, Node node)
          Deprecated.  
 void setCloseOnComplete(boolean close)
          Deprecated. Set the serializer to close (true) or leave open (false) the Writer upon completion of a serialization.
 void setMethod(int method)
          Deprecated. Sets the serialization method to method.
 void setPreferences()
          Deprecated. Reads the current serializer preferences using a PropertyManager.
 void setWriter(Writer writer)
          Deprecated. Set the Writer used by this XMLSerializer.
protected  void write(Node node)
          Deprecated. Output a DOM Node (such as a Document) to the output stream.
protected  void write(Node node, int nest)
          Deprecated. Output the specified DOM Node object, printing it using the specified indentation string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

prettyPrint

public boolean prettyPrint
Deprecated. 
Variable controlling whether to include whitespace indenting. (default true).


XMLSPACE_ATTR

public static final String XMLSPACE_ATTR
Deprecated. 
The XML attribute 'xml:space'.

See Also:
Constant Field Values

XMLSPACE_DEFAULT

public static final String XMLSPACE_DEFAULT
Deprecated. 
The value 'default' for the XML 'xml:space' attribute.

See Also:
Constant Field Values

XMLSPACE_PRESERVE

public static final String XMLSPACE_PRESERVE
Deprecated. 
The value 'preserve' for the XML 'xml:space' attribute.

See Also:
Constant Field Values

addXMLDecl

public boolean addXMLDecl
Deprecated. 
Variable controlling whether XML comments should be preceded by a XML Declaration if they don't already have on (default false).


expandCommentWS

public boolean expandCommentWS
Deprecated. 
Variable controlling whether XML comments should be preceded by a newline (default false).


DOCTYPE_XHTML_STRICT

public static final int DOCTYPE_XHTML_STRICT
Deprecated. 
Used by getDoctypeDeclaration() to indicate the XHTML 1.0 Strict DTD.

See Also:
Constant Field Values

DOCTYPE_XHTML_TRANSITIONAL

public static final int DOCTYPE_XHTML_TRANSITIONAL
Deprecated. 
Used by getDoctypeDeclaration() to indicate the XHTML 1.0 Transitional DTD.

See Also:
Constant Field Values

DOCTYPE_XHTML_FRAMESET

public static final int DOCTYPE_XHTML_FRAMESET
Deprecated. 
Used by getDoctypeDeclaration() to indicate the XHTML 1.0 Frameset DTD.

See Also:
Constant Field Values

DOCTYPE_SHML_2

public static final int DOCTYPE_SHML_2
Deprecated. 
Used by getDoctypeDeclaration() to indicate the SHML 2.0 DTD.

See Also:
Constant Field Values

encoding

public static String encoding
Deprecated. 
The String used as the content of the XML declaration's encoding attribute.


XMLNS_shml

public static final String XMLNS_shml
Deprecated. 
The URI indicating the SHML 2.0 XML namespace.

See Also:
Constant Field Values

SHML_DTD_PubId

public static final String SHML_DTD_PubId
Deprecated. 
A String containing the Formal Public Identifier (FPI) for the SHML 2.0 DTD.

See Also:
Constant Field Values

SHML_DTD_SysId

public static String SHML_DTD_SysId
Deprecated. 
A String containing a system identifier for the SHML 2.0 DTD.


emptyXHTML

public String emptyXHTML
Deprecated. 
A space-delimited list of XHTML elements declared EMPTY. This is set by the property
http://purl.org/ceryle/prop/plink/#emptyXHTMLElements
.


inlineXHTML

public String inlineXHTML
Deprecated. 
A space-delimited list of XHTML elements considered (by the HTML 4 Recommendation) as inline. This is set by the property
http://purl.org/ceryle/prop/plink/#inlineXHTMLElements
.


blockXHTML

public String blockXHTML
Deprecated. 
A space-delimited list of a subset of XHTML elements considered as block elements. These elements receive a trailing newline. This is set by the property
http://purl.org/ceryle/prop/plink/#blockXHTMLElements
.


emptyXTM

public String emptyXTM
Deprecated. 
A space-delimited list of XTM elements declared EMPTY.


m_closeOnComplete

protected boolean m_closeOnComplete
Deprecated. 
Variable controlling whether to close the writer upon completion. Default is true.

Constructor Detail

XMLSerializer

public XMLSerializer(Writer out)
Deprecated. 

Constructor with an MessageHandler mh and Writer out. Uses the default XML serialization method.


XMLSerializer

public XMLSerializer(Writer out,
                     int method)
Deprecated. 

Constructor with an MessageHandler mh and Writer out, and serialization method method.

See Also:
XMLUtils.SERIALIZE_XML, XMLUtils.SERIALIZE_XTM, XMLUtils.SERIALIZE_XHTML, XMLUtils.SERIALIZE_HTML, XMLUtils.SERIALIZE_TEXT
Method Detail

getSerializedNode

public static String getSerializedNode(Node node)
Deprecated. 

A static method that returns a serialization of the provided DOM Node using an XML serialization method.


serializeNode

public static String serializeNode(MessageHandler mh,
                                   Node node)
Deprecated. 

A static method used to return a String serialization of the provided Node node, defaulting to the serialization method XMLUtils.SERIALIZE_XML. This a convenience method.


setMethod

public void setMethod(int method)
Deprecated. 
Sets the serialization method to method.


setCloseOnComplete

public void setCloseOnComplete(boolean close)
Deprecated. 
Set the serializer to close (true) or leave open (false) the Writer upon completion of a serialization. The default (absent being modified by this method) is to close the Writer.


serializeDocument

public void serializeDocument(Node node)
                       throws IOException
Deprecated. 
Output a DOM Node (such as a Document) to the output stream, closing the writer when complete. This one of the two non-static public methods initiating a serialization. If closeOnComplete is false, only a buffer flush will occur following serialization, otherwise the Writer will be closed.

Throws:
IOException

serializeElementContent

public void serializeElementContent(Element element)
                             throws IOException
Deprecated. 
Output an Element Node to the output stream, closing the writer when complete. Note that this does not include the start and end tags of the Element itself, only its children. This is one of two non-static public methods initiating a serialization. If closeOnComplete is false, only a buffer flush will occur following serialization, otherwise the Writer will be closed.

Throws:
IOException

setPreferences

public void setPreferences()
                    throws IOException
Deprecated. 
Reads the current serializer preferences using a PropertyManager. Depending on the currently-set method, reads the named properties:
http://purl.org/ceryle/prop/plink/#emptyXHTMLElements
a space-separated list of XHTML elements declared EMPTY
http://purl.org/ceryle/prop/plink/#inlineXHTMLElements
a space-separated list of inline XHTML elements
http://purl.org/ceryle/prop/plink/#blockXHTMLElements
a space-separated list of a subset of the block XHTML elements
http://purl.org/ceryle/prop/plink/#emptyXTMElements
a space-separated list of XTM elements declared EMPTY

Throws:
IOException

setWriter

public void setWriter(Writer writer)
Deprecated. 
Set the Writer used by this XMLSerializer. The existing Writer is closed (with any exceptions trapped) and then simply replaced by the new Writer.


close

public void close()
           throws IOException
Deprecated. 
Close the output stream.

Throws:
IOException

write

protected void write(Node node)
              throws IOException
Deprecated. 
Output a DOM Node (such as a Document) to the output stream.

Throws:
IOException

write

protected void write(Node node,
                     int nest)
              throws IOException
Deprecated. 
Output the specified DOM Node object, printing it using the specified indentation string

Throws:
IOException

getDoctypeDeclaration

public static String getDoctypeDeclaration(int type)
Deprecated. 

A static method which returns a String containing a DOCTYPE declaration, depending on the value of the int type. Supported values include:
  • DOCTYPE_XHTML_STRICT : XHTML 1.0 Strict
  • DOCTYPE_XHTML_TRANSITIONAL : XHTML 1.0 Transitional
  • DOCTYPE_XHTML_FRAMESET : XHTML 1.0 Frameset
  • DOCTYPE_SHML_2 : SHML 2.0
Default value is XHTML 1.0 Strict (used if type is not an accepted value).



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.