public abstract class FormatCallout {
protected static final String foURI = "http://www.w3.org/1999/XSL/Format";
protected static final String xhURI = "http://www.w3.org/1999/xhtml";
+ protected String uri = "";
protected boolean foStylesheet = false;
+ protected boolean xhStylesheet = false;
protected NamePool namePool = null;
- public FormatCallout(NamePool nPool, boolean fo) {
+ public FormatCallout(NamePool nPool, boolean fo, boolean xhtml) {
namePool = nPool;
foStylesheet = fo;
+ xhStylesheet = xhtml;
}
public String areaLabel(Element area) {
return id;
}
-
public void startSpan(Emitter rtf, String id)
throws TransformerException {
-
+
if (!foStylesheet && namePool != null) {
- int spanName = namePool.allocate("", "", "span");
+ if(xhStylesheet) {
+ uri = xhURI;
+ }
+
+
+ int spanName = namePool.allocate("", uri, "span");
+
AttributeCollection spanAttr = new AttributeCollection(namePool);
int namespaces[] = new int[1];
- spanAttr.addAttribute("", "", "class", "CDATA", "co");
- spanAttr.addAttribute("", "", "id", "CDATA", id);
+ spanAttr.addAttribute("", uri, "class", "CDATA", "co");
+ spanAttr.addAttribute("", uri, "id", "CDATA", id);
rtf.startElement(spanName, spanAttr, namespaces, 0);
}
-
}
public void endSpan(Emitter rtf)
throws TransformerException {
if (!foStylesheet && namePool != null) {
- int spanName = namePool.allocate("", "", "span");
+ if (xhStylesheet) {
+ uri = xhURI;
+ }
+ int spanName = namePool.allocate("", uri, "span");
rtf.endElement(spanName);
}
}
int graphicsMax = 0;
String iconSize = "";
- public FormatGraphicCallout(NamePool nPool, String path, String ext, int max, String size, boolean fo) {
- super(nPool, fo);
+ public FormatGraphicCallout(NamePool nPool, String path, String ext, int max,
+ String size, boolean fo, boolean xhtml) {
+ super(nPool, fo, xhtml);
graphicsPath = path;
graphicsExt = ext;
graphicsMax = max;
imgAttr.addAttribute("", "", "content-width", "CDATA", iconSize);
imgAttr.addAttribute("", "", "width", "CDATA", iconSize);
- // HTML
- } else {
- imgName = namePool.allocate("", "", "img");
+ // XHTML/HTML
+ } else {
+ if (xhStylesheet) {
+ imgName = namePool.allocate("", xhURI, "img");
+ }
+ else {
+ imgName = namePool.allocate("", "", "img");
+ }
+
imgAttr = new AttributeCollection(namePool);
imgAttr.addAttribute("", "", "src", "CDATA",
graphicsPath + num + graphicsExt);
**/
public class FormatTextCallout extends FormatCallout {
- public FormatTextCallout(NamePool nPool, boolean fo) {
- super(nPool, fo);
+ public FormatTextCallout(NamePool nPool, boolean fo, boolean xhtml) {
+ super(nPool, fo, xhtml);
}
public void formatCallout(Emitter rtfEmitter,
String font,
int start,
int max,
- boolean fo) {
- super(nPool, fo);
+ boolean fo,
+ boolean xhtml) {
+ super(nPool, fo, xhtml);
unicodeFont = font;
unicodeMax = max;
unicodeStart = start;
inAttr.addAttribute("", "", "id", "ID", id);
} else {
- inName = namePool.allocate("", "", "font");
+ if (xhStylesheet) {
+ inName = namePool.allocate("", xhURI, "font");
+ } else {
+ inName = namePool.allocate("", "", "font");
+ }
+
inAttr = new AttributeCollection(namePool);
inAttr.addAttribute("", "", "face", "CDATA", unicodeFont);
inAttr.addAttribute("", "", "id", "ID", id);
public class Verbatim {
/** True if the stylesheet is producing formatting objects */
private static boolean foStylesheet = false;
+ /** True if the stylesheet is producing XHTML */
+ private static boolean xhStylesheet = false;
/** The modulus for line numbering (every 'modulus' line is numbered). */
private static int modulus = 0;
/** The width (in characters) of line numbers (for padding). */
LineCountEmitter lcEmitter = new LineCountEmitter();
rtf.replay(lcEmitter);
int numLines = lcEmitter.lineCount();
-
+
int listingModulus = numLines < modulus ? 1 : modulus;
double log10numLines = Math.log(numLines) / Math.log(10);
graphicsMax = 0;
iconSize = "7pt";
foStylesheet = false;
+ xhStylesheet = false;
calloutsSetup = true;
Value variable = null;
// Get the stylesheet type
varString = getVariable(context, "stylesheet.result.type");
foStylesheet = (varString.equals("fo"));
+ xhStylesheet = (varString.equals("xhtml"));
// Get the default column
varString = getVariable(context, "callout.defaultcolumn");
graphicsExt,
graphicsMax,
iconSize,
- foStylesheet);
+ foStylesheet,
+ xhStylesheet);
} else if (useUnicode) {
// Get the starting character
varString = getVariable(context, "callout.unicode.start.character");
unicodeFont,
unicodeStart,
unicodeMax,
- foStylesheet);
+ foStylesheet,
+ xhStylesheet);
} else {
- fCallout = new FormatTextCallout(namePool, foStylesheet);
+ fCallout = new FormatTextCallout(namePool, foStylesheet, xhStylesheet);
}
}