org.apache.xml.serializer

Class ToHTMLStream

public final class ToHTMLStream extends ToStream

This serializer takes a series of SAX or SAX-like events and writes its output to the given stream. This class is not a public API, it is public because it is used from another package.

UNKNOWN: internal

Constructor Summary
ToHTMLStream()
Default constructor.
Method Summary
voidaddUniqueAttribute(String name, String value, int flags)
This method is used to add an attribute to the currently open element.
voidattributeDecl(String eName, String aName, String type, String valueDefault, String value)
This method does nothing.
voidcdata(char[] ch, int start, int length)
Receive notification of cdata.
voidcharacters(char[] chars, int start, int length)
Receive notification of character data.
voidcomment(char[] ch, int start, int length)
voidelementDecl(String name, String model)
This method does nothing.
voidendDocument()
Receive notification of the end of a document.
voidendDTD()
Report the end of DTD declarations.
voidendElement(String namespaceURI, String localName, String name)
Receive notification of the end of an element.
voidendElement(String elemName)
voidentityReference(String name)
Receive notivication of a entityReference.
voidexternalEntityDecl(String name, String publicId, String systemId)
This method does nothing.
static ElemDescgetElemDesc(String name)
Get a description of the given element.
voidinternalEntityDecl(String name, String value)
This method does nothing.
voidnamespaceAfterStartElement(String prefix, String uri)
This method is used when a prefix/uri namespace mapping is indicated after the element was started with a startElement() and before and endElement(). startPrefixMapping(prefix,uri) would be used before the startElement() call.
voidprocessAttributes(Writer writer, int nAttrs)
Process the attributes, which means to write out the currently collected attributes to the writer.
voidprocessingInstruction(String target, String data)
Receive notification of a processing instruction.
booleanreset()
voidsetOmitMetaTag(boolean bool)
Tells if the formatter should omit the META tag.
voidsetOutputFormat(Properties format)
Specifies an output format for this serializer.
voidsetOutputStream(OutputStream output)
Specifies an output stream to which the document should be serialized.
voidsetSpecialEscapeURLs(boolean bool)
Tells if the formatter should use special URL escaping.
voidstartDTD(String name, String publicId, String systemId)
voidstartElement(String namespaceURI, String localName, String name, Attributes atts)
Receive notification of the beginning of an element.
voidwriteAttrString(Writer writer, String string, String encoding)
Writes the specified string after substituting specials, and UTF-16 surrogates for character references &#xnn.
voidwriteAttrURI(Writer writer, String string, boolean doURLEscaping)
Write the specified string after substituting non ASCII characters, with %HH, where HH is the hex of the byte value.

Constructor Detail

ToHTMLStream

public ToHTMLStream()
Default constructor.

Method Detail

addUniqueAttribute

public void addUniqueAttribute(String name, String value, int flags)
This method is used to add an attribute to the currently open element. The caller has guaranted that this attribute is unique, which means that it not been seen before and will not be seen again.

Parameters: name the qualified name of the attribute value the value of the attribute which can contain only ASCII printable characters characters in the range 32 to 127 inclusive. flags the bit values of this integer give optimization information.

attributeDecl

public void attributeDecl(String eName, String aName, String type, String valueDefault, String value)
This method does nothing.

cdata

public final void cdata(char[] ch, int start, int length)
Receive notification of cdata.

The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.

The application must not attempt to read from the array outside of the specified range.

Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).

Parameters: ch The characters from the XML document. start The start position in the array. length The number of characters to read from the array.

Throws: org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. org.xml.sax.SAXException

See Also: ToHTMLStream org.xml.sax.Locator

characters

public final void characters(char[] chars, int start, int length)
Receive notification of character data.

The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.

The application must not attempt to read from the array outside of the specified range.

Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).

Parameters: chars The characters from the XML document. start The start position in the array. length The number of characters to read from the array.

Throws: org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. org.xml.sax.SAXException

See Also: ToHTMLStream org.xml.sax.Locator

comment

public void comment(char[] ch, int start, int length)

elementDecl

public void elementDecl(String name, String model)
This method does nothing.

endDocument

public final void endDocument()
Receive notification of the end of a document.

Throws: org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. org.xml.sax.SAXException

endDTD

public void endDTD()
Report the end of DTD declarations.

Throws: org.xml.sax.SAXException The application may raise an exception.

See Also: ToHTMLStream

endElement

public final void endElement(String namespaceURI, String localName, String name)
Receive notification of the end of an element.

Parameters: namespaceURI localName name The element type name

Throws: org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception.

endElement

public final void endElement(String elemName)

See Also: endElement

entityReference

public final void entityReference(String name)
Receive notivication of a entityReference.

Parameters: name non-null reference to entity name string.

Throws: org.xml.sax.SAXException

externalEntityDecl

public void externalEntityDecl(String name, String publicId, String systemId)
This method does nothing.

getElemDesc

public static final ElemDesc getElemDesc(String name)
Get a description of the given element.

Parameters: name non-null name of element, case insensitive.

Returns: non-null reference to ElemDesc, which may be m_dummy if no element description matches the given name.

internalEntityDecl

public void internalEntityDecl(String name, String value)
This method does nothing.

namespaceAfterStartElement

public void namespaceAfterStartElement(String prefix, String uri)
This method is used when a prefix/uri namespace mapping is indicated after the element was started with a startElement() and before and endElement(). startPrefixMapping(prefix,uri) would be used before the startElement() call.

Parameters: uri the URI of the namespace prefix the prefix associated with the given URI.

See Also: ExtendedContentHandler

processAttributes

public void processAttributes(Writer writer, int nAttrs)
Process the attributes, which means to write out the currently collected attributes to the writer. The attributes are not cleared by this method

Parameters: writer the writer to write processed attributes to. nAttrs the number of attributes in m_attributes to be processed

Throws: org.xml.sax.SAXException

processingInstruction

public void processingInstruction(String target, String data)
Receive notification of a processing instruction.

Parameters: target The processing instruction target. data The processing instruction data, or null if none was supplied.

Throws: org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. org.xml.sax.SAXException

reset

public boolean reset()

setOmitMetaTag

public void setOmitMetaTag(boolean bool)
Tells if the formatter should omit the META tag.

Parameters: bool True if the META tag should be omitted.

setOutputFormat

public void setOutputFormat(Properties format)
Specifies an output format for this serializer. It the serializer has already been associated with an output format, it will switch to the new format. This method should not be called while the serializer is in the process of serializing a document. This method can be called multiple times before starting the serialization of a particular result-tree. In principle all serialization parameters can be changed, with the exception of method="html" (it must be method="html" otherwise we shouldn't even have a ToHTMLStream object here!)

Parameters: format The output format or serialzation parameters to use.

setOutputStream

public void setOutputStream(OutputStream output)
Specifies an output stream to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document.

The encoding specified in the output properties is used, or if no encoding was specified, the default for the selected output method.

Parameters: output The output stream

setSpecialEscapeURLs

public void setSpecialEscapeURLs(boolean bool)
Tells if the formatter should use special URL escaping.

Parameters: bool True if URLs should be specially escaped with the %xx form.

startDTD

public void startDTD(String name, String publicId, String systemId)

startElement

public void startElement(String namespaceURI, String localName, String name, Attributes atts)
Receive notification of the beginning of an element.

Parameters: namespaceURI localName name The element type name. atts The attributes attached to the element, if any.

Throws: org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception.

See Also: ToHTMLStream org.xml.sax.AttributeList

writeAttrString

public void writeAttrString(Writer writer, String string, String encoding)
Writes the specified string after substituting specials, and UTF-16 surrogates for character references &#xnn.

Parameters: string String to convert to XML format. encoding CURRENTLY NOT IMPLEMENTED.

Throws: org.xml.sax.SAXException

writeAttrURI

public void writeAttrURI(Writer writer, String string, boolean doURLEscaping)
Write the specified string after substituting non ASCII characters, with %HH, where HH is the hex of the byte value.

Parameters: string String to convert to XML format. doURLEscaping True if we should try to encode as per http://www.ietf.org/rfc/rfc2396.txt.

Throws: org.xml.sax.SAXException if a bad surrogate pair is detected.

Copyright B) 2005 Apache XML Project. All Rights Reserved.