|
|||||||||
| Home >> All >> com >> nwalsh >> [ xalan overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.nwalsh.xalan
Class Verbatim

java.lang.Objectcom.nwalsh.xalan.Verbatim
- public class Verbatim
- extends java.lang.Object
Xalan extensions supporting DocBook verbatim environments
Copyright (C) 2001 Norman Walsh.
This class provides a Xalan implementation of two features that would be impractical to implement directly in XSLT: line numbering and callouts.
Line Numbering
The numberLines family of functions takes a result tree fragment (assumed to contain the contents of a formatted verbatim element in DocBook: programlisting, screen, address, literallayout, or synopsis) and returns a result tree fragment decorated with line numbers.
Callouts
The insertCallouts family of functions takes an areaspec and a result tree fragment (assumed to contain the contents of a formatted verbatim element in DocBook: programlisting, screen, address, literallayout, or synopsis) and returns a result tree fragment decorated with callouts.
Change Log:
- 1.0
Initial release.
| Field Summary | |
private Callout[] |
callout
The (sorted) array of callouts obtained from the areaspec. |
private int |
calloutCount
The number of callouts in the callout array. |
private int |
calloutPos
A pointer used to keep track of our position in the callout array. |
private int |
colNumber
The current column number. |
private java.util.Stack |
elementStack
A stack to hold the open elements while walking through a RTF. |
private static java.lang.String |
foURI
|
private java.lang.String |
graphicsExt
The extension to use for graphical callout decorations. |
private boolean |
graphicsFO
Should graphic callouts use fo:external-graphics or imgs. |
private int |
graphicsMax
The largest callout number that can be represented graphically. |
private java.lang.String |
graphicsPath
The path to use for graphical callout decorations. |
private int |
lineNumber
The current line number. |
private int |
modulus
The modulus for line numbering (every 'modulus' line is numbered). |
private java.lang.String |
separator
The separator between the line number and the verbatim text. |
private java.util.Stack |
tempStack
A stack to hold the temporarily closed elements. |
private int |
width
The width (in characters) of line numbers (for padding). |
private static java.lang.String |
xhURI
|
| Constructor Summary | |
Verbatim()
Constructor for Verbatim |
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
elementStack
private java.util.Stack elementStack
- A stack to hold the open elements while walking through a RTF.
tempStack
private java.util.Stack tempStack
- A stack to hold the temporarily closed elements.
lineNumber
private int lineNumber
- The current line number.
colNumber
private int colNumber
- The current column number.
modulus
private int modulus
- The modulus for line numbering (every 'modulus' line is numbered).
width
private int width
- The width (in characters) of line numbers (for padding).
separator
private java.lang.String separator
- The separator between the line number and the verbatim text.
callout
private Callout[] callout
- The (sorted) array of callouts obtained from the areaspec.
calloutCount
private int calloutCount
- The number of callouts in the callout array.
calloutPos
private int calloutPos
- A pointer used to keep track of our position in the callout array.
graphicsPath
private java.lang.String graphicsPath
- The path to use for graphical callout decorations.
graphicsExt
private java.lang.String graphicsExt
- The extension to use for graphical callout decorations.
graphicsMax
private int graphicsMax
- The largest callout number that can be represented graphically.
graphicsFO
private boolean graphicsFO
- Should graphic callouts use fo:external-graphics or imgs.
foURI
private static final java.lang.String foURI
- See Also:
- Constant Field Values
xhURI
private static final java.lang.String xhURI
- See Also:
- Constant Field Values
| Constructor Detail |
Verbatim
public Verbatim()
Constructor for Verbatim
All of the methods are static, so the constructor does nothing.
| Method Detail |
numberLines
public org.w3c.dom.DocumentFragment numberLines(org.apache.xalan.extensions.ExpressionContext context, org.w3c.dom.traversal.NodeIterator xalanNI)
Number lines in a verbatim environment.
This method adds line numbers to a result tree fragment. Each newline that occurs in a text node is assumed to start a new line. The first line is always numbered, every subsequent xalanMod line is numbered (so if xalanMod=5, lines 1, 5, 10, 15, etc. will be numbered. If there are fewer than xalanMod lines in the environment, every line is numbered.
xalanMod is taken from the $linenumbering.everyNth parameter.
Every line number will be right justified in a string xalanWidth characters long. If the line number of the last line in the environment is too long to fit in the specified width, the width is automatically increased to the smallest value that can hold the number of the last line. (In other words, if you specify the value 2 and attempt to enumerate the lines of an environment that is 100 lines long, the value 3 will automatically be used for every line in the environment.)
xalanWidth is taken from the $linenumbering.width parameter.
The xalanSep string is inserted between the line number and the original program listing. Lines that aren't numbered are preceded by a xalanWidth blank string and the separator.
xalanSep is taken from the $linenumbering.separator parameter.
If inline markup extends across line breaks, markup changes are required. All the open elements are closed before the line break and "reopened" afterwards. The reopened elements will have the same attributes as the originals, except that 'name' and 'id' attributes are not duplicated.
countLineBreaks
private int countLineBreaks(org.w3c.dom.Node node)
Count the number of lines in a verbatim environment.
This method walks over the nodes of a DocumentFragment and returns the number of lines breaks that it contains.
lineNumberFragment
private void lineNumberFragment(org.apache.xml.utils.DOMBuilder rtf, org.w3c.dom.Node node)
Build a DocumentFragment with numbered lines.
This is the method that actually does the work of numbering lines in a verbatim environment. It recursively walks through a tree of nodes, copying the structure into the rtf. Text nodes are examined for new lines and modified as requested by the global line numbering parameters.
When called, rtf should be an empty DocumentFragment and node should be the first child of the result tree fragment that contains the existing, formatted verbatim text.
formatLineNumber
private void formatLineNumber(org.apache.xml.utils.DOMBuilder rtf, int lineNumber)
Add a formatted line number to the result tree fragment.
This method examines the global parameters that control line number presentation (modulus, width, and separator) and adds the appropriate text to the result tree fragment.
insertCallouts
public org.w3c.dom.DocumentFragment insertCallouts(org.apache.xalan.extensions.ExpressionContext context, org.w3c.dom.traversal.NodeIterator areaspecNodeSet, org.w3c.dom.traversal.NodeIterator xalanNI)
Insert graphical callouts into a verbatim environment.
This method examines the areaset and area elements in the supplied areaspec and decorates the supplied result tree fragment with appropriate callout markers.
If a label attribute is supplied on an area, its content will be used for the label, otherwise the callout number will be used. Callouts are numbered in document order. All of the areas in an areaset get the same number.
If the callout number is not greater than gMax, the callout generated will be:
<img src="$gPath/conumber$gExt" alt="conumber">
Otherwise, it will be the callout number surrounded by parenthesis.
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. Lines will be padded with blanks to reach the necessary column, but callouts that are located beyond the last line of the verbatim environment will be ignored.
Callouts are inserted before the character at the line/column where they are to occur.
insertGraphicCallouts
public org.w3c.dom.DocumentFragment insertGraphicCallouts(org.w3c.dom.traversal.NodeIterator areaspecNodeSet, org.w3c.dom.traversal.NodeIterator xalanNI, int defaultColumn, java.lang.String gPath, java.lang.String gExt, int gMax, boolean useFO)
insertUnicodeCallouts
public org.w3c.dom.DocumentFragment insertUnicodeCallouts(org.w3c.dom.traversal.NodeIterator areaspecNodeSet, org.w3c.dom.traversal.NodeIterator xalanNI, int defaultColumn, int uStart, int uMax, boolean useFO)
insertDingbatCallouts
public org.w3c.dom.DocumentFragment insertDingbatCallouts(org.w3c.dom.traversal.NodeIterator areaspecNodeSet, org.w3c.dom.traversal.NodeIterator xalanNI, int defaultColumn, int gMax, boolean useFO)
insertTextCallouts
public org.w3c.dom.DocumentFragment insertTextCallouts(org.w3c.dom.traversal.NodeIterator areaspecNodeSet, org.w3c.dom.traversal.NodeIterator xalanNI, int defaultColumn, boolean useFO)
insertCallouts
public org.w3c.dom.DocumentFragment insertCallouts(org.w3c.dom.traversal.NodeIterator areaspecNodeSet, org.w3c.dom.traversal.NodeIterator xalanNI, int defaultColumn, FormatCallout fCallout)
calloutFragment
private void calloutFragment(org.apache.xml.utils.DOMBuilder rtf, org.w3c.dom.Node node, FormatCallout fCallout)
Build a FragmentValue with callout decorations.
This is the method that actually does the work of adding callouts to a verbatim environment. It recursively walks through a tree of nodes, copying the structure into the rtf. Text nodes are examined for the position of callouts as described by the global callout parameters.
When called, rtf should be an empty FragmentValue and node should be the first child of the result tree fragment that contains the existing, formatted verbatim text.
addCallout
private void addCallout(int coNum,
org.w3c.dom.Node node,
int defaultColumn)
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.
formatPad
private void formatPad(org.apache.xml.utils.DOMBuilder rtf, 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.
closeOpenElements
private void closeOpenElements(org.apache.xml.utils.DOMBuilder rtf) throws org.xml.sax.SAXException
openClosedElements
private void openClosedElements(org.apache.xml.utils.DOMBuilder rtf) throws org.xml.sax.SAXException
copyAttributes
private org.xml.sax.Attributes copyAttributes(org.w3c.dom.Element node)
|
|||||||||
| Home >> All >> com >> nwalsh >> [ xalan overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.nwalsh.xalan.Verbatim