Package net.sf.saxon.serialize
Class HTMLEmitter
- java.lang.Object
-
- net.sf.saxon.serialize.Emitter
-
- net.sf.saxon.serialize.XMLEmitter
-
- net.sf.saxon.serialize.HTMLEmitter
-
- All Implemented Interfaces:
javax.xml.transform.Result
,Receiver
public class HTMLEmitter extends XMLEmitter
This class generates HTML output- Author:
- Michael H. Kay
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static HTMLTagHashSet
emptyTags
Table of HTML tags that have no closing tag-
Fields inherited from class net.sf.saxon.serialize.XMLEmitter
characterReferenceGenerator, declarationIsWritten, elementCode, elementStack, indentForNextAttribute, openStartTag, specialInAtt, specialInText, started, startedElement, undeclareNamespaces
-
Fields inherited from class net.sf.saxon.serialize.Emitter
allCharactersEncodable, characterSet, namePool, outputProperties, outputStream, pipelineConfig, streamResult, systemId, writer
-
-
Constructor Summary
Constructors Constructor Description HTMLEmitter()
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
characters(java.lang.CharSequence chars, int locationId, int properties)
Character data.void
endElement()
Output an element end tag.protected static boolean
isEmptyTag(java.lang.String tag)
void
open()
Output start of documentprotected void
openDocument()
Do the real work of starting the document.void
processingInstruction(java.lang.String target, java.lang.CharSequence data, int locationId, int properties)
Handle a processing instruction.void
setEscapeNonAscii(java.lang.Boolean escape)
Say that all non-ASCII characters should be escaped, regardless of the character encodingvoid
startContent()
Notify the start of the content, that is, the completion of all attributes and namespaces.void
startElement(NodeName elemName, SchemaType typeCode, int locationId, int properties)
Output element start tagprotected void
writeAttribute(NodeName elCode, java.lang.String attname, java.lang.CharSequence value, int properties)
Write attribute name=value pair.protected void
writeDocType(java.lang.String type, java.lang.String systemId, java.lang.String publicId)
Output the document type declarationprotected void
writeEscape(java.lang.CharSequence chars, boolean inAttribute)
Escape characters.-
Methods inherited from class net.sf.saxon.serialize.XMLEmitter
attribute, close, closeStartTag, comment, emptyElementTagCloser, endDocument, getAttributeIndentString, namespace, setCharacterReferenceGenerator, setIndentForNextAttribute, startDocument, testCharacters, usesTypeAnnotations, writeCharSequence, writeDeclaration
-
Methods inherited from class net.sf.saxon.serialize.Emitter
getConfiguration, getOutputProperties, getOutputStream, getPipelineConfiguration, getSystemId, getWriter, makeOutputStream, makeWriter, setOutputProperties, setOutputStream, setPipelineConfiguration, setStreamResult, setSystemId, setUnparsedEntity, setWriter, usesWriter
-
-
-
-
Field Detail
-
emptyTags
static HTMLTagHashSet emptyTags
Table of HTML tags that have no closing tag
-
-
Method Detail
-
isEmptyTag
protected static boolean isEmptyTag(java.lang.String tag)
-
setEscapeNonAscii
public void setEscapeNonAscii(java.lang.Boolean escape)
Say that all non-ASCII characters should be escaped, regardless of the character encoding- Overrides:
setEscapeNonAscii
in classXMLEmitter
- Parameters:
escape
- true if all non ASCII characters should be escaped
-
open
public void open() throws XPathException
Output start of document- Specified by:
open
in interfaceReceiver
- Overrides:
open
in classXMLEmitter
- Throws:
XPathException
- if an error occurs
-
openDocument
protected void openDocument() throws XPathException
Description copied from class:XMLEmitter
Do the real work of starting the document. This happens when the first content is written.- Overrides:
openDocument
in classXMLEmitter
- Throws:
XPathException
- f an error occurs opening the output file
-
writeDocType
protected void writeDocType(java.lang.String type, java.lang.String systemId, java.lang.String publicId) throws XPathException
Output the document type declaration- Overrides:
writeDocType
in classXMLEmitter
- Parameters:
type
- The element namesystemId
- The DOCTYP system identifierpublicId
- The DOCTYPE public identifier- Throws:
XPathException
- if an error occurs writing to the output
-
startElement
public void startElement(NodeName elemName, SchemaType typeCode, int locationId, int properties) throws XPathException
Output element start tag- Specified by:
startElement
in interfaceReceiver
- Overrides:
startElement
in classXMLEmitter
- Parameters:
elemName
- the name of the element.typeCode
- the type annotation of the element.locationId
- an integer which can be interpreted using aLocationProvider
to return information such as line number and system ID. If no location information is available, the value zero is supplied.properties
- bit-significant properties of the element node. If there are no revelant properties, zero is supplied. The definitions of the bits are in classReceiverOptions
- Throws:
XPathException
- if an error occurs
-
startContent
public void startContent() throws XPathException
Description copied from interface:Receiver
Notify the start of the content, that is, the completion of all attributes and namespaces. Note that the initial receiver of output from XSLT instructions will not receive this event, it has to detect it itself. Note that this event is reported for every element even if it has no attributes, no namespaces, and no content.- Specified by:
startContent
in interfaceReceiver
- Overrides:
startContent
in classXMLEmitter
- Throws:
XPathException
- if an error occurs
-
writeAttribute
protected void writeAttribute(NodeName elCode, java.lang.String attname, java.lang.CharSequence value, int properties) throws XPathException
Write attribute name=value pair. Overrides the XML behaviour if the name and value are the same (we assume this is a boolean attribute to be minimised), or if the value is a URL.- Overrides:
writeAttribute
in classXMLEmitter
- Parameters:
elCode
- The element name is not used in this version of the method, but is used in the HTML subclass.attname
- The attribute name, which has already been validated to ensure it can be written in this encodingvalue
- The value of the attributeproperties
- Any special properties of the attribute- Throws:
XPathException
- if an error occurs
-
writeEscape
protected void writeEscape(java.lang.CharSequence chars, boolean inAttribute) throws java.io.IOException, XPathException
Escape characters. Overrides the XML behaviour- Overrides:
writeEscape
in classXMLEmitter
- Parameters:
chars
- The character sequence containing the stringinAttribute
- Set to true if the text is in an attribute value- Throws:
java.io.IOException
XPathException
-
endElement
public void endElement() throws XPathException
Output an element end tag.- Specified by:
endElement
in interfaceReceiver
- Overrides:
endElement
in classXMLEmitter
- Throws:
XPathException
- if an error occurs
-
characters
public void characters(java.lang.CharSequence chars, int locationId, int properties) throws XPathException
Character data.- Specified by:
characters
in interfaceReceiver
- Overrides:
characters
in classXMLEmitter
- Parameters:
chars
- The characterslocationId
- an integer which can be interpreted using aLocationProvider
to return information such as line number and system ID. If no location information is available, the value zero is supplied.properties
- Bit significant value. The following bits are defined:- DISABLE_ESCAPING
- Disable escaping for this text node
- USE_CDATA
- Output as a CDATA section
- Throws:
XPathException
- if an error occurs
-
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.CharSequence data, int locationId, int properties) throws XPathException
Handle a processing instruction.- Specified by:
processingInstruction
in interfaceReceiver
- Overrides:
processingInstruction
in classXMLEmitter
- Parameters:
target
- The PI name. This must be a legal name (it will not be checked).data
- The data portion of the processing instructionlocationId
- an integer which can be interpreted using aLocationProvider
to return information such as line number and system ID. If no location information is available, the value zero is supplied.properties
- Additional information about the PI.- Throws:
XPathException
- if an error occurs
-
-