Package net.sf.saxon.serialize
Class HTMLEmitter
- java.lang.Object
-
- net.sf.saxon.event.SequenceReceiver
-
- net.sf.saxon.serialize.Emitter
-
- net.sf.saxon.serialize.XMLEmitter
-
- net.sf.saxon.serialize.HTMLEmitter
-
- All Implemented Interfaces:
javax.xml.transform.Result,Receiver,ReceiverWithOutputProperties
- Direct Known Subclasses:
HTML40Emitter,HTML50Emitter
public abstract class HTMLEmitter extends XMLEmitter
This class generates HTML output
-
-
Field Summary
Fields Modifier and Type Field Description protected intversion-
Fields inherited from class net.sf.saxon.serialize.XMLEmitter
attSpecials, canonical, characterReferenceGenerator, declarationIsWritten, delimiter, elementCode, elementStack, indentForNextAttribute, openStartTag, started, startedElement, undeclareNamespaces, unfailing
-
Fields inherited from class net.sf.saxon.serialize.Emitter
allCharactersEncodable, characterSet, outputProperties, outputStream, streamResult, writer
-
Fields inherited from class net.sf.saxon.event.SequenceReceiver
pipelineConfiguration, previousAtomic, systemId
-
-
Constructor Summary
Constructors Constructor Description HTMLEmitter()Constructor
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcharacters(java.lang.CharSequence chars, Location locationId, int properties)Character data.protected java.lang.StringemptyElementTagCloser(java.lang.String displayName, NodeName nameCode)Close an empty element tag.voidendElement()Output an element end tag.protected static booleanisEmptyTag(java.lang.String tag)protected abstract booleanisHTMLElement(NodeName name)Decide whether an element is "serialized as an HTML element" in the language of the 3.0 specificationvoidopen()Output start of documentprotected voidopenDocument()Do the real work of starting the document.voidprocessingInstruction(java.lang.String target, java.lang.CharSequence data, Location locationId, int properties)Handle a processing instruction.protected abstract booleanrejectControlCharacters()Ask whether control characters should be rejected: true for HTML4, false for HTML5protected static voidsetEmptyTag(java.lang.String tag)voidsetEscapeNonAscii(java.lang.Boolean escape)Say that all non-ASCII characters should be escaped, regardless of the character encodingvoidstartContentOLD()voidstartElement(NodeName elemName, SchemaType type, AttributeMap attributes, NamespaceMap namespaces, Location location, int properties)Output element start tagprotected voidwriteAttribute(NodeName elCode, java.lang.String attname, java.lang.CharSequence value, int properties)Write attribute name=value pair.protected voidwriteDocType(NodeName name, java.lang.String displayName, java.lang.String systemId, java.lang.String publicId)Output the document type declarationprotected voidwriteEscape(java.lang.CharSequence chars, boolean inAttribute)Escape characters.-
Methods inherited from class net.sf.saxon.serialize.XMLEmitter
close, closeStartTag, comment, convertToAscii, endDocument, getAttributeIndentString, isStarted, namespace, setCharacterReferenceGenerator, setIndentForNextAttribute, startDocument, testCharacters, usesTypeAnnotations, writeCharSequence, writeDeclaration, writeDocTypeWithNullSystemId
-
Methods inherited from class net.sf.saxon.serialize.Emitter
append, getOutputProperties, getOutputStream, getWriter, makeOutputStream, makeWriter, setOutputProperties, setOutputStream, setStreamResult, setUnparsedEntity, setWriter, usesWriter
-
Methods inherited from class net.sf.saxon.event.SequenceReceiver
append, decompose, flatten, getConfiguration, getErrorCodeForDecomposingFunctionItems, getNamePool, getPipelineConfiguration, getSystemId, handlesAppend, setPipelineConfiguration, setSystemId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.event.Receiver
append, getPipelineConfiguration, handlesAppend, setPipelineConfiguration, setSystemId
-
-
-
-
Method Detail
-
setEmptyTag
protected static void setEmptyTag(java.lang.String tag)
-
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:
setEscapeNonAsciiin classXMLEmitter- Parameters:
escape- true if all non ASCII characters should be escaped
-
isHTMLElement
protected abstract boolean isHTMLElement(NodeName name)
Decide whether an element is "serialized as an HTML element" in the language of the 3.0 specification- Returns:
- true if the element is to be serialized as an HTML element
-
open
public void open() throws XPathExceptionOutput start of document- Specified by:
openin interfaceReceiver- Overrides:
openin classXMLEmitter- Throws:
XPathException- if an error occurs
-
openDocument
protected void openDocument() throws XPathExceptionDescription copied from class:XMLEmitterDo the real work of starting the document. This happens when the first content is written.- Overrides:
openDocumentin classXMLEmitter- Throws:
XPathException- if an error occurs opening the output file
-
writeDocType
protected void writeDocType(NodeName name, java.lang.String displayName, java.lang.String systemId, java.lang.String publicId) throws XPathException
Output the document type declaration- Overrides:
writeDocTypein classXMLEmitter- Parameters:
displayName- The element namesystemId- The DOCTYPE system identifierpublicId- The DOCTYPE public identifiername- the qualified name of the element- Throws:
XPathException- if an error occurs writing to the output
-
startElement
public void startElement(NodeName elemName, SchemaType type, AttributeMap attributes, NamespaceMap namespaces, Location location, int properties) throws XPathException
Output element start tag- Specified by:
startElementin interfaceReceiver- Overrides:
startElementin classXMLEmitter- Parameters:
elemName- the name of the element.type- the type annotation of the element.attributes- the attributes of this elementnamespaces- the in-scope namespaces of this element: generally this is all the in-scope namespaces, without relying on inheriting namespaces from parent elementslocation- an object providing information about the module, line, and column where the node originatedproperties- bit-significant properties of the element node. If there are no relevant properties, zero is supplied. The definitions of the bits are in classReceiverOption- Throws:
XPathException- if an error occurs
-
startContentOLD
public void startContentOLD() throws XPathException- Throws:
XPathException
-
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:
writeAttributein 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, XPathExceptionEscape characters. Overrides the XML behaviour- Overrides:
writeEscapein classXMLEmitter- Parameters:
chars- The character sequence containing the stringinAttribute- Set to true if the text is in an attribute value- Throws:
java.io.IOExceptionXPathException
-
rejectControlCharacters
protected abstract boolean rejectControlCharacters()
Ask whether control characters should be rejected: true for HTML4, false for HTML5- Returns:
- true if control characters should be rejected
-
emptyElementTagCloser
protected java.lang.String emptyElementTagCloser(java.lang.String displayName, NodeName nameCode)Close an empty element tag. (This is overridden in XHTMLEmitter).- Overrides:
emptyElementTagCloserin classXMLEmitter- Parameters:
displayName- the name of the empty elementnameCode- the fingerprint of the name of the empty element- Returns:
- the string used to close an empty element tag.
-
endElement
public void endElement() throws XPathExceptionOutput an element end tag.- Specified by:
endElementin interfaceReceiver- Overrides:
endElementin classXMLEmitter- Throws:
XPathException- if an error occurs
-
characters
public void characters(java.lang.CharSequence chars, Location locationId, int properties) throws XPathExceptionCharacter data.- Specified by:
charactersin interfaceReceiver- Overrides:
charactersin classXMLEmitter- Parameters:
chars- The characterslocationId- provides information such as line number and system ID.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, Location locationId, int properties) throws XPathExceptionHandle a processing instruction.- Specified by:
processingInstructionin interfaceReceiver- Overrides:
processingInstructionin 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- provides information such as line number and system ID.properties- Additional information about the PI.- Throws:
XPathException- if an error occurs
-
-