]> granicus.if.org Git - docbook-dsssl/commitdiff
Added fixes to ensure that generated XHTML markup for callouts is in the proper names...
authorMauritz Jeanson <mj@johanneberg.com>
Wed, 2 May 2012 17:57:07 +0000 (17:57 +0000)
committerMauritz Jeanson <mj@johanneberg.com>
Wed, 2 May 2012 17:57:07 +0000 (17:57 +0000)
xsl-saxon/src/com/nwalsh/saxon/FormatCallout.java
xsl-saxon/src/com/nwalsh/saxon/FormatGraphicCallout.java
xsl-saxon/src/com/nwalsh/saxon/FormatTextCallout.java
xsl-saxon/src/com/nwalsh/saxon/FormatUnicodeCallout.java
xsl-saxon/src/com/nwalsh/saxon/Verbatim.java

index 2c4e3487745fc7cde1d6d245247126d87dc8cf77..bdb4c593997a1a3eee00baf86cca47e9e60a333d 100644 (file)
@@ -34,12 +34,15 @@ import com.nwalsh.saxon.Callout;
 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) {
@@ -82,26 +85,33 @@ public abstract class FormatCallout {
     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);
     }
   }
index eade5940376b76e7280426f659d0194e9915e20a..fde0409ce34857d2f5d4c5021aca556262bf7795 100644 (file)
@@ -37,8 +37,9 @@ public class FormatGraphicCallout extends FormatCallout {
   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;
@@ -72,9 +73,15 @@ public class FormatGraphicCallout extends FormatCallout {
          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);
index 263c913b901df18c4009f01b6b85e04ad01a7a3a..4de640585b9f20a2c3363feeda61ea44dabbdb1c 100644 (file)
@@ -27,8 +27,8 @@ import com.nwalsh.saxon.Callout;
  **/
 
 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,
index 21b5599eec0f199dcdf43c813989ba2ab1ca5409..90bf33c737d78cc605b157a196a68a10a847dabb 100644 (file)
@@ -39,8 +39,9 @@ public class FormatUnicodeCallout extends FormatCallout {
                              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;
@@ -72,7 +73,12 @@ public class FormatUnicodeCallout extends FormatCallout {
            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);
index f817645b81c3211c06ee9a0fda3efa9a46b302ec..33d7328ec3151d007afc171f14f6bb9ba7e68596 100644 (file)
@@ -56,6 +56,8 @@ import com.nwalsh.saxon.CalloutEmitter;
 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). */
@@ -246,7 +248,7 @@ public class Verbatim {
       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);
@@ -326,6 +328,7 @@ public class Verbatim {
     graphicsMax = 0;
     iconSize = "7pt";
     foStylesheet = false;
+    xhStylesheet = false;
     calloutsSetup = true;
 
     Value variable = null;
@@ -334,6 +337,7 @@ public class Verbatim {
     // 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");
@@ -382,7 +386,8 @@ public class Verbatim {
                                          graphicsExt,
                                          graphicsMax,
                                          iconSize,
-                                         foStylesheet);
+                                         foStylesheet,
+                                         xhStylesheet);
     } else if (useUnicode) {
       // Get the starting character
       varString = getVariable(context, "callout.unicode.start.character");
@@ -414,9 +419,10 @@ public class Verbatim {
                                          unicodeFont,
                                          unicodeStart,
                                          unicodeMax,
-                                         foStylesheet);
+                                         foStylesheet,
+                                         xhStylesheet);
     } else {
-      fCallout = new FormatTextCallout(namePool, foStylesheet);
+      fCallout = new FormatTextCallout(namePool, foStylesheet, xhStylesheet);
     }
   }