
com.nwalsh.xalan.FormatUnicodeCallout Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docbook-xsl-xalan Show documentation
Show all versions of docbook-xsl-xalan Show documentation
These are Java extensions for use with the DocBook XML stylesheets and the Xalan-Java XSLT engine.
The newest version!
package com.nwalsh.xalan;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.SAXException;
import org.w3c.dom.*;
import org.apache.xml.utils.DOMBuilder;
import com.nwalsh.xalan.Callout;
import org.apache.xml.utils.AttList;
/**
* Utility class for the Verbatim extension (ignore this).
*
* $Id: FormatUnicodeCallout.java 7007 2007-07-11 07:09:12Z mzjn $
*
* Copyright (C) 2000, 2001 Norman Walsh.
*
* Change Log:
*
* - 1.0
* Initial release.
*
*
* @author Norman Walsh
* [email protected]
*
* @see Verbatim
*
* @version $Id: FormatUnicodeCallout.java 7007 2007-07-11 07:09:12Z mzjn $
**/
public class FormatUnicodeCallout extends FormatCallout {
int unicodeMax = 0;
int unicodeStart = 0;
String unicodeFont = "";
public FormatUnicodeCallout(String font, int start, int max, boolean fo) {
unicodeFont = font;
unicodeMax = max;
unicodeStart = start;
stylesheetFO = fo;
}
public void formatCallout(DOMBuilder rtf,
Callout callout) {
Element area = callout.getArea();
int num = callout.getCallout();
String label = areaLabel(area);
String id = areaID(area);
try {
if (label == null && num <= unicodeMax) {
AttributesImpl inAttr = new AttributesImpl();
String ns = "";
String prefix = "";
String inName = "";
if (!unicodeFont.equals("")) {
if (stylesheetFO) {
ns = foURI;
prefix = "fo:";
inName = "inline";
inAttr.addAttribute("", "", "font-family", "CDATA", unicodeFont);
inAttr.addAttribute("", "", "id", "ID", id);
} else {
inName = "font";
inAttr.addAttribute("", "", "face", "CDATA", unicodeFont);
inAttr.addAttribute("", "", "id", "ID", id);
}
}
char chars[] = new char[1];
chars[0] = (char) (unicodeStart + num - 1);
startSpan(rtf, id);
if (!unicodeFont.equals("")) {
rtf.startElement(ns, inName, prefix+inName, inAttr);
}
rtf.characters(chars, 0, 1);
if (!unicodeFont.equals("")) {
rtf.endElement(ns, inName, prefix+inName);
}
endSpan(rtf);
} else {
formatTextCallout(rtf, callout);
}
} catch (SAXException e) {
System.out.println("SAX Exception in unicode formatCallout");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy