All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nwalsh.saxon.ColumnUpdateEmitter Maven / Gradle / Ivy

Go to download

These are Java extensions for use with the DocBook XML stylesheets and the Saxon XSLT engine.

The newest version!
package com.nwalsh.saxon;

import javax.xml.transform.TransformerException;

import com.icl.saxon.Controller;
import com.icl.saxon.om.NamePool;
import com.icl.saxon.tree.AttributeCollection;

/**
 * 

Saxon extension to scan the column widths in a result tree fragment.

* *

$Id: ColumnUpdateEmitter.java 8483 2009-07-13 20:33:56Z mzjn $

* *

Copyright (C) 2000 Norman Walsh.

* *

This class provides a * Saxon 6.* * implementation to scan the column widths in a result tree * fragment.

* *

The general design is this: the stylesheets construct a result tree * fragment for some colgroup environment. That result tree fragment * is "replayed" through the ColumnUpdateEmitter; the ColumnUpdateEmitter watches * the cols go by and extracts the column widths that it sees. These * widths are then made available.

* *

Change Log:

*
*
1.0
*

Initial release.

*
* * @author Norman Walsh * [email protected] * * @version $Id: ColumnUpdateEmitter.java 8483 2009-07-13 20:33:56Z mzjn $ * */ public class ColumnUpdateEmitter extends CopyEmitter { /** The number of columns seen. */ protected int numColumns = 0; protected String width[] = null; protected NamePool namePool = null; /** The FO namespace name. */ protected static String foURI = "http://www.w3.org/1999/XSL/Format"; /** The XHTML namespace name. */ protected static String xhtmlURI = "http://www.w3.org/1999/xhtml"; /** Construct a new ColumnUpdateEmitter. */ public ColumnUpdateEmitter(Controller controller, NamePool namePool, String width[]) { super(controller, namePool); numColumns = 0; this.width = width; this.namePool = namePool; } /** Examine for column info. */ public void startElement(int nameCode, org.xml.sax.Attributes attributes, int[] namespaces, int nscount) throws TransformerException { int thisFingerprint = namePool.getFingerprint(nameCode); int colFingerprint = namePool.getFingerprint("", "col"); int XHTMLcolFingerprint = namePool.getFingerprint(xhtmlURI, "col"); int foColFingerprint = namePool.getFingerprint(foURI, "table-column"); if (thisFingerprint == colFingerprint || thisFingerprint == XHTMLcolFingerprint ) { AttributeCollection attr = new AttributeCollection(namePool, attributes); int widthFingerprint = namePool.getFingerprint("", "width"); if (attr.getValueByFingerprint(widthFingerprint) == null) { attr.addAttribute(widthFingerprint, "CDATA", width[numColumns++]); } else { attr.setAttribute(widthFingerprint, "CDATA", width[numColumns++]); } attributes = attr; } else if (thisFingerprint == foColFingerprint) { AttributeCollection attr = new AttributeCollection(namePool, attributes); int widthFingerprint = namePool.getFingerprint("", "column-width"); if (attr.getValueByFingerprint(widthFingerprint) == null) { attr.addAttribute(widthFingerprint, "CDATA", width[numColumns++]); } else { attr.setAttribute(widthFingerprint, "CDATA", width[numColumns++]); } attributes = attr; } rtfEmitter.startElement(nameCode, attributes, namespaces, nscount); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy