| com.nwalsh.saxon.CopyEmitter com.nwalsh.saxon.NumberLinesEmitter
NumberLinesEmitter | public class NumberLinesEmitter extends CopyEmitter (Code) | | Saxon extension to decorate a result tree fragment with line numbers.
$Id: NumberLinesEmitter.java,v 1.1 2006/05/31 17:21:20 mbatchelor Exp $
Copyright (C) 2000 Norman Walsh.
This class provides the guts of a
Saxon 6.*
implementation of line numbering 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 NumberLinesEmitter with information about what lines should be
numbered and how. Then the result tree fragment
is "replayed" through the NumberLinesEmitter; the NumberLinesEmitter
builds a
new result tree fragment from this event stream, decorated with line
numbers,
and that is returned.
Change Log:
- 1.0
Initial release.
See Also: Verbatim author: Norman Walsh author: ndw@nwalsh.com version: $Id: NumberLinesEmitter.java,v 1.1 2006/05/31 17:21:20 mbatchelor Exp $ |
Field Summary | |
protected Stack | elementStack A stack for the preserving information about open elements. | protected boolean | firstElement | protected boolean | foStylesheet | protected static String | foURI The FO namespace name. | protected int | lineNumber The current line number. | protected int | modulus Every modulus line will be numbered. | protected String | separator Line numbers are separated from the listing by separator . | protected int | startinglinenumber The first line number will be startinglinenumber . | protected int | width Line numbers are width characters wide. | protected static String | xhURI The XHTML namespace name. |
Constructor Summary | |
public | NumberLinesEmitter(Controller controller, NamePool namePool, int startingLineNumber, int modulus, int width, String separator, boolean foStylesheet) |
Method Summary | |
public void | characters(char[] chars, int start, int len) Process characters. | public void | endElement(int nameCode) Process end element events. | protected void | formatLineNumber(int lineNumber) | 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). | public void | startElement(int nameCode, org.xml.sax.Attributes attributes, int[] namespaces, int nscount) Process start element events. |
elementStack | protected Stack elementStack(Code) | | A stack for the preserving information about open elements.
|
firstElement | protected boolean firstElement(Code) | | Is the next element absolutely the first element in the fragment?
|
foStylesheet | protected boolean foStylesheet(Code) | | Is the stylesheet currently running an FO stylesheet?
|
foURI | protected static String foURI(Code) | | The FO namespace name.
|
lineNumber | protected int lineNumber(Code) | | The current line number.
|
modulus | protected int modulus(Code) | | Every modulus line will be numbered.
|
separator | protected String separator(Code) | | Line numbers are separated from the listing by separator .
|
startinglinenumber | protected int startinglinenumber(Code) | | The first line number will be startinglinenumber .
|
width | protected int width(Code) | | Line numbers are width characters wide.
|
xhURI | protected static String xhURI(Code) | | The XHTML namespace name.
|
NumberLinesEmitter | public NumberLinesEmitter(Controller controller, NamePool namePool, int startingLineNumber, int modulus, int width, String separator, boolean foStylesheet)(Code) | | Constructor for the NumberLinesEmitter.
Parameters: namePool - The name pool to use for constructing elements and attributes. Parameters: modulus - The modulus to use for this listing. Parameters: width - The width to use for line numbers in this listing. Parameters: separator - The separator to use for this listing. Parameters: foStylesheet - Is this an FO stylesheet? |
formatLineNumber | protected void formatLineNumber(int lineNumber) throws TransformerException(Code) | | Add a formatted line number to the result tree fragment.
Parameters: lineNumber - The number of the current line. |
skipThisElement | protected boolean skipThisElement(int nameCode)(Code) | | 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 True if the element is the outer-most block, false otherwise. |
|
|