Class CalloutEmitter
- All Implemented Interfaces:
Result
Saxon extension to decorate a result tree fragment with callouts.
$Id: CalloutEmitter.java 5907 2006-04-27 08:26:47Z xmldoc $
Copyright (C) 2000 Norman Walsh.
This class provides the guts of a Saxon 6.* implementation of callouts for verbatim environments. (It is used by the Verbatim class.)
The general design is this: the stylesheets construct a result tree fragment for some verbatim environment. The Verbatim class initializes a CalloutEmitter with information about the callouts that should be applied to the verbatim environment in question. Then the result tree fragment is "replayed" through the CalloutEmitter; the CalloutEmitter builds a new result tree fragment from this event stream, decorated with callouts, and that is returned.
Change Log:
- 1.0
Initial release.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
The default column for callouts that specify only a line.protected Stack
A stack for the preserving information about open elements.protected boolean
Is the next element absolutely the first element in the fragment?protected boolean
Is the stylesheet currently running an FO stylesheet?protected static String
The FO namespace name.protected Stack
A stack for holding information about temporarily closed elements.protected static String
The XHTML namespace name.Fields inherited from class com.nwalsh.saxon.CopyEmitter
namePool, rtf, rtfEmitter
Fields inherited from class com.icl.saxon.output.Emitter
locator, outputProperties, outputStream, systemId, writer
Fields inherited from interface javax.xml.transform.Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING
-
Constructor Summary
ConstructorsConstructorDescriptionCalloutEmitter
(com.icl.saxon.Controller controller, com.icl.saxon.om.NamePool namePool, int defaultColumn, boolean foStylesheet, FormatCallout fCallout) Constructor for the CalloutEmitter. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addCallout
(int coNum, Node node, int defaultColumn) Add a callout to the global callout arrayvoid
characters
(char[] chars, int start, int len) Process characters.void
endElement
(int nameCode) Process end element events.protected void
formatPad
(int numBlanks) Add blanks to the result tree fragment.void
setupCallouts
(NodeList areaspecNodeList) Examine the areaspec and determine the number and position of callouts.protected boolean
skipThisElement
(int nameCode) Protect the outer-most block wrapper.void
startElement
(int nameCode, Attributes attributes, int[] namespaces, int nscount) Process start element events.Methods inherited from class com.nwalsh.saxon.CopyEmitter
comment, endDocument, getResultTreeFragment, processingInstruction, setDocumentLocator, setEscaping, setNamePool, setUnparsedEntity, setWriter, startDocument
Methods inherited from class com.icl.saxon.output.Emitter
getNamePool, getOutputProperties, getOutputStream, getSystemId, getWriter, makeEmitter, setOutputProperties, setOutputStream, setSystemId, usesWriter
-
Field Details
-
elementStack
A stack for the preserving information about open elements. -
tempStack
A stack for holding information about temporarily closed elements. -
firstElement
protected boolean firstElementIs the next element absolutely the first element in the fragment? -
foURI
The FO namespace name. -
xhURI
The XHTML namespace name. -
defaultColumn
protected int defaultColumnThe default column for callouts that specify only a line. -
foStylesheet
protected boolean foStylesheetIs the stylesheet currently running an FO stylesheet?
-
-
Constructor Details
-
CalloutEmitter
public CalloutEmitter(com.icl.saxon.Controller controller, com.icl.saxon.om.NamePool namePool, int defaultColumn, boolean foStylesheet, FormatCallout fCallout) Constructor for the CalloutEmitter.
- Parameters:
controller
-namePool
- The name pool to use for constructing elements and attributes.defaultColumn
- The default column for callouts.foStylesheet
- Is this an FO stylesheet?fCallout
-
-
-
Method Details
-
setupCallouts
Examine the areaspec and determine the number and position of callouts.
The
areaspecNodeSet
is examined and a sorted list of the callouts is constructed.This data structure is used to augment the result tree fragment with callout bullets.
- Parameters:
areaspecNodeList
- The source document <areaspec> element.
-
characters
Process characters.- Overrides:
characters
in classCopyEmitter
- Throws:
TransformerException
-
formatPad
protected void formatPad(int numBlanks) Add blanks to the result tree fragment.
This method adds numBlanks to the result tree fragment. It's used to pad lines when callouts occur after the last existing characater in a line.
- Parameters:
numBlanks
- The number of blanks to add.
-
addCallout
Add a callout to the global callout array
This method examines a callout area and adds it to the global callout array if it can be interpreted.
Only the linecolumn and linerange units are supported. If no unit is specifed, linecolumn is assumed. If only a line is specified, the callout decoration appears in the defaultColumn.
- Parameters:
coNum
- The callout number.node
- The area.defaultColumn
- The default column for callouts.
-
endElement
Process end element events.- Overrides:
endElement
in classCopyEmitter
- Throws:
TransformerException
-
startElement
public void startElement(int nameCode, Attributes attributes, int[] namespaces, int nscount) throws TransformerException Process start element events.- Overrides:
startElement
in classCopyEmitter
- Throws:
TransformerException
-
skipThisElement
protected boolean skipThisElement(int nameCode) Protect the outer-most block wrapper.
Open elements in the result tree fragment are closed and reopened around callouts (so that callouts don't appear inside links or other environments). But if the result tree fragment is a single block (a div or pre in HTML, an fo:block in FO), that outer-most block is treated specially.
This method returns true if the element in question is that outermost block.
- Parameters:
nameCode
- The name code for the element- Returns:
- True if the element is the outer-most block, false otherwise.
-