Class Table
- java.lang.Object
-
- com.nwalsh.xalan.Table
-
public class Table extends java.lang.ObjectXalan extensions supporting Tables
$Id: Table.java 6886 2007-06-26 18:03:49Z mzjn $
Copyright (C) 2000 Norman Walsh.
This class provides a Xalan implementation of some code to adjust CALS Tables to HTML Tables.
Column Widths
The adjustColumnWidths method takes a result tree fragment (assumed to contain the colgroup of an HTML Table) and returns the result tree fragment with the column widths adjusted to HTML terms.
Convert Lengths
The convertLength method takes a length specification of the form 9999.99xx (where "xx" is a unit) and returns that length as an integral number of pixels. For convenience, percentage lengths are returned unchanged.
The recognized units are: inches (in), centimeters (cm), millimeters (mm), picas (pc, 1pc=12pt), points (pt), and pixels (px). A number with no units is assumed to be pixels.
Change Log:
- 1.0
Initial release.
-
-
Constructor Summary
Constructors Constructor Description Table()Constructor for Verbatim
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.w3c.dom.DocumentFragmentadjustColumnWidths(org.apache.xalan.extensions.ExpressionContext context, org.w3c.dom.traversal.NodeIterator xalanNI)Adjust column widths in an HTML table.static intconvertLength(java.lang.String length)Convert a length specification to a number of pixels.protected java.lang.String[]correctRoundingError(java.lang.String[] widths)Correct rounding errors introduced in calculating the width of each column.intgetPixelsPerInch()Return the current pixels-per-inch value.protected static voidinitializeHash()Initialize the internal hash table with proper values.static voidsetPixelsPerInch(int value)Set the pixels-per-inch value.
-
-
-
Method Detail
-
initializeHash
protected static void initializeHash()
Initialize the internal hash table with proper values.
-
setPixelsPerInch
public static void setPixelsPerInch(int value)
Set the pixels-per-inch value. Only positive values are legal.
-
getPixelsPerInch
public int getPixelsPerInch()
Return the current pixels-per-inch value.
-
convertLength
public static int convertLength(java.lang.String length)
Convert a length specification to a number of pixels.
The specified length should be of the form [+/-]999.99xx, where xx is a valid unit.
-
adjustColumnWidths
public org.w3c.dom.DocumentFragment adjustColumnWidths(org.apache.xalan.extensions.ExpressionContext context, org.w3c.dom.traversal.NodeIterator xalanNI)Adjust column widths in an HTML table.
The specification of column widths in CALS (a relative width plus an optional absolute width) are incompatible with HTML column widths. This method adjusts CALS column width specifiers in an attempt to produce equivalent HTML specifiers.
In order for this method to work, the CALS width specifications should be placed in the "width" attribute of the <col>s within a <colgroup>. Then the colgroup result tree fragment is passed to this method.
This method makes use of two parameters from the XSL stylesheet that calls it:
nominal.table.widthandtable.width. The value ofnominal.table.widthmust be an absolute distance. The value oftable.widthcan be either absolute or relative.Presented with a mixture of relative and absolute lengths, the table width is used to calculate appropriate values. If the
table.widthis relative, the nominal width is used for this calculation.There are three possible combinations of values:
- There are no relative widths; in this case the absolute widths are used in the HTML table.
- There are no absolute widths; in this case the relative widths are used in the HTML table.
- There are a mixture of absolute and relative widths:
- If the table width is absolute, all widths become absolute.
- If the table width is relative, make all the widths absolute relative to the nominal table width then turn them all back into relative widths.
- Parameters:
context- The stylesheet context; supplied automatically by XalanxalanNI-- Returns:
- The result tree fragment containing the adjusted colgroup.
-
correctRoundingError
protected java.lang.String[] correctRoundingError(java.lang.String[] widths)
Correct rounding errors introduced in calculating the width of each column. Make sure they sum to 100% in the end.
-
-