| 1 |
package com.nwalsh.saxon; |
| 2 |
|
| 3 |
import org.xml.sax.*; |
| 4 |
import com.icl.saxon.output.*; |
| 5 |
import com.icl.saxon.Controller; |
| 6 |
import com.icl.saxon.om.*; |
| 7 |
import javax.xml.transform.TransformerException; |
| 8 |
import com.icl.saxon.expr.FragmentValue; |
| 9 |
import com.icl.saxon.tree.AttributeCollection; |
| 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 |
|
| 40 |
|
| 41 |
public class ColumnUpdateEmitter extends CopyEmitter { |
| 42 |
|
| 43 |
protected int numColumns = 0; |
| 44 |
protected String width[] = null; |
| 45 |
protected NamePool namePool = null; |
| 46 |
|
| 47 |
|
| 48 |
protected static String foURI = "http://www.w3.org/1999/XSL/Format"; |
| 49 |
|
| 50 |
|
| 51 |
public ColumnUpdateEmitter(Controller controller, |
| 52 |
NamePool namePool, |
| 53 |
String width[]) { |
| 54 |
super(controller, namePool); |
| 55 |
numColumns = 0; |
| 56 |
this.width = width; |
| 57 |
this.namePool = namePool; |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
public void startElement(int nameCode, |
| 62 |
org.xml.sax.Attributes attributes, |
| 63 |
int[] namespaces, int nscount) |
| 64 |
throws TransformerException { |
| 65 |
|
| 66 |
int thisFingerprint = namePool.getFingerprint(nameCode); |
| 67 |
int colFingerprint = namePool.getFingerprint("", "col"); |
| 68 |
int foColFingerprint = namePool.getFingerprint(foURI, "table-column"); |
| 69 |
|
| 70 |
if (thisFingerprint == colFingerprint) { |
| 71 |
AttributeCollection attr = new AttributeCollection(namePool, attributes); |
| 72 |
int widthFingerprint = namePool.getFingerprint("", "width"); |
| 73 |
|
| 74 |
if (attr.getValueByFingerprint(widthFingerprint) == null) { |
| 75 |
attr.addAttribute(widthFingerprint, "CDATA", width[numColumns++]); |
| 76 |
} else { |
| 77 |
attr.setAttribute(widthFingerprint, "CDATA", width[numColumns++]); |
| 78 |
} |
| 79 |
attributes = attr; |
| 80 |
} else if (thisFingerprint == foColFingerprint) { |
| 81 |
AttributeCollection attr = new AttributeCollection(namePool, attributes); |
| 82 |
int widthFingerprint = namePool.getFingerprint("", "column-width"); |
| 83 |
|
| 84 |
if (attr.getValueByFingerprint(widthFingerprint) == null) { |
| 85 |
attr.addAttribute(widthFingerprint, "CDATA", width[numColumns++]); |
| 86 |
} else { |
| 87 |
attr.setAttribute(widthFingerprint, "CDATA", width[numColumns++]); |
| 88 |
} |
| 89 |
attributes = attr; |
| 90 |
} |
| 91 |
|
| 92 |
rtfEmitter.startElement(nameCode, attributes, namespaces, nscount); |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
|