| 1 |
package com.nwalsh.saxon; |
| 2 |
|
| 3 |
import org.xml.sax.*; |
| 4 |
import javax.xml.transform.TransformerException; |
| 5 |
import com.icl.saxon.output.*; |
| 6 |
import com.icl.saxon.om.*; |
| 7 |
import com.icl.saxon.expr.FragmentValue; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public class ColumnScanEmitter extends com.icl.saxon.output.Emitter { |
| 40 |
|
| 41 |
protected int numColumns = 0; |
| 42 |
protected String width[] = new String[5]; |
| 43 |
protected NamePool namePool = null; |
| 44 |
|
| 45 |
|
| 46 |
protected static String foURI = "http://www.w3.org/1999/XSL/Format"; |
| 47 |
|
| 48 |
|
| 49 |
public ColumnScanEmitter(NamePool namePool) { |
| 50 |
numColumns = 0; |
| 51 |
this.namePool = namePool; |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
public int columnCount() { |
| 56 |
return numColumns; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
public String[] columnWidths() { |
| 61 |
|
| 62 |
String rWidth[] = new String[numColumns]; |
| 63 |
for (int count = 0; count < numColumns; count++) { |
| 64 |
rWidth[count] = width[count]; |
| 65 |
} |
| 66 |
return rWidth; |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
public void characters(char[] chars, int start, int len) |
| 71 |
throws TransformerException { |
| 72 |
|
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
public void comment(char[] chars, int start, int length) |
| 77 |
throws TransformerException { |
| 78 |
|
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
public void endDocument() |
| 83 |
throws TransformerException { |
| 84 |
|
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
public void endElement(int nameCode) |
| 89 |
throws TransformerException { |
| 90 |
|
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
public void processingInstruction(java.lang.String name, |
| 95 |
java.lang.String data) |
| 96 |
throws TransformerException { |
| 97 |
|
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
public void setDocumentLocator(org.xml.sax.Locator locator) { |
| 102 |
|
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
public void setEscaping(boolean escaping) |
| 107 |
throws TransformerException { |
| 108 |
|
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
public void setNamePool(NamePool namePool) { |
| 113 |
|
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
public void setUnparsedEntity(java.lang.String name, java.lang.String uri) |
| 118 |
throws TransformerException { |
| 119 |
|
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
public void setWriter(java.io.Writer writer) { |
| 124 |
|
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
public void startDocument() |
| 129 |
throws TransformerException { |
| 130 |
|
| 131 |
} |
| 132 |
|
| 133 |
|
| 134 |
public void startElement(int nameCode, |
| 135 |
org.xml.sax.Attributes attributes, |
| 136 |
int[] namespaces, int nscount) |
| 137 |
throws TransformerException { |
| 138 |
|
| 139 |
int thisFingerprint = namePool.getFingerprint(nameCode); |
| 140 |
int colFingerprint = namePool.getFingerprint("", "col"); |
| 141 |
int foColFingerprint = namePool.getFingerprint(foURI, "table-column"); |
| 142 |
|
| 143 |
if (thisFingerprint == colFingerprint |
| 144 |
|| thisFingerprint == foColFingerprint) { |
| 145 |
if (numColumns >= width.length) { |
| 146 |
String newWidth[] = new String[width.length+10]; |
| 147 |
for (int count = 0; count < width.length; count++) { |
| 148 |
newWidth[count] = width[count]; |
| 149 |
} |
| 150 |
width = newWidth; |
| 151 |
} |
| 152 |
|
| 153 |
if (thisFingerprint == colFingerprint) { |
| 154 |
if (attributes.getValue("width") == null) { |
| 155 |
width[numColumns++] = "1*"; |
| 156 |
} else { |
| 157 |
width[numColumns++] = attributes.getValue("width"); |
| 158 |
} |
| 159 |
} else { |
| 160 |
if (attributes.getValue("column-width") == null) { |
| 161 |
width[numColumns++] = "1*"; |
| 162 |
} else { |
| 163 |
width[numColumns++] = attributes.getValue("column-width"); |
| 164 |
} |
| 165 |
} |
| 166 |
} |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
|