]> granicus.if.org Git - docbook-dsssl/commitdiff
fix table/cell borders for wordml, fix formal figure, add emphasis-strong
authorSteve Ball <balls@users.sourceforge.net>
Thu, 3 Apr 2008 06:58:34 +0000 (06:58 +0000)
committerSteve Ball <balls@users.sourceforge.net>
Thu, 3 Apr 2008 06:58:34 +0000 (06:58 +0000)
xsl/roundtrip/blocks2dbk.xsl
xsl/roundtrip/wordml2normalise.xsl

index 51b8fa46a40a9a18f0fa72eda05f1a124c726344..debeb753892850f3f1503346674a1b6197f2601c 100644 (file)
@@ -69,7 +69,7 @@
     <xsl:variable name='figure'
                  select='preceding-sibling::dbk:para[dbk:inlinemediaobject and count(*) = 1 and normalize-space(.) = ""][1]'/>
     <xsl:variable name='caption'
-                 select='following-sibling::dbk:para[@rnd:style = "caption"]'/>
+                 select='following-sibling::dbk:para[@rnd:style = "caption" or @rnd:style = "Caption"]'/>
 
     <xsl:choose>
       <!-- continue style paragraphs are handled in context -->
@@ -94,7 +94,7 @@
                      @rnd:style = "figure-title" and
                      following-sibling::*[1][self::dbk:para][dbk:inlinemediaobject and count(*) = 1 and normalize-space(.) = ""]'/>
       <xsl:when test='$suppress and
-                     @rnd:style = "caption" and
+                     (@rnd:style = "caption" or @rnd:style = "Caption") and
                      (preceding-sibling::*[self::dbk:informaltable] or
                      preceding-sibling::*[self::dbk:para][dbk:inlinemediaobject and count(*) = 1 and normalize-space(.) = ""])'/>
 
       </xsl:when>
 
       <xsl:when test='@rnd:style = "informalfigure-imagedata"'>
-        <dbk:informalfigure>
-          <xsl:call-template name='rnd:attributes'/>
-          <dbk:mediaobject>
-            <dbk:imageobject>
-              <dbk:imagedata fileref='{.}'/>
-            </dbk:imageobject>
-          </dbk:mediaobject>
-          <xsl:apply-templates select='following-sibling::*[1][self::dbk:para][@rnd:style = "caption"]'
-            mode='rnd:caption'/>
-        </dbk:informalfigure>
+        <xsl:choose>
+          <xsl:when test='preceding-sibling::*[1][self::dbk:para][@rnd:style = "figure-title"]'>
+            <dbk:figure>
+              <xsl:call-template name='rnd:attributes'/>
+              <dbk:info>
+                <dbk:title>
+                  <xsl:apply-templates select='preceding-sibling::*[1]/node()'/>
+                </dbk:title>
+              </dbk:info>
+              <dbk:mediaobject>
+                <dbk:imageobject>
+                  <dbk:imagedata fileref='{.}'/>
+                </dbk:imageobject>
+              </dbk:mediaobject>
+              <xsl:apply-templates select='following-sibling::*[1][self::dbk:para][@rnd:style = "caption" or @rnd:style = "Caption"]'
+                mode='rnd:caption'/>
+            </dbk:figure>
+          </xsl:when>
+          <xsl:otherwise>
+            <dbk:informalfigure>
+              <xsl:call-template name='rnd:attributes'/>
+              <dbk:mediaobject>
+                <dbk:imageobject>
+                  <dbk:imagedata fileref='{.}'/>
+                </dbk:imageobject>
+              </dbk:mediaobject>
+              <xsl:apply-templates select='following-sibling::*[1][self::dbk:para][@rnd:style = "caption" or @rnd:style = "Caption"]'
+                mode='rnd:caption'/>
+            </dbk:informalfigure>
+          </xsl:otherwise>
+        </xsl:choose>
       </xsl:when>
 
-      <xsl:when test='@rnd:style = "caption" and
+      <xsl:when test='(@rnd:style = "caption" or @rnd:style = "Caption") and
                       preceding-sibling::*[(self::dbk:para and contains(@rnd:style, "imagedata")) or self::dbk:informaltable]'/>
-      <xsl:when test='@rnd:style = "caption"'>
+      <xsl:when test='@rnd:style = "caption" or @rnd:style = "Caption"'>
         <xsl:call-template name='rnd:error'>
           <xsl:with-param name='code'>bad-caption</xsl:with-param>
           <xsl:with-param name='message'>caption does not follow table or figure</xsl:with-param>
         </xsl:copy>
       </xsl:when>
 
-      <xsl:when test='@rnd:style = preceding-sibling::node()[self::dbk:emphasis]/@rnd:style'/>
+      <xsl:when test='@rnd:style = preceding-sibling::node()[1][self::dbk:emphasis]/@rnd:style'/>
 
       <xsl:when test='@rnd:style = "emphasis"'>
         <xsl:copy>
           <xsl:apply-templates mode='rnd:copy'/>
         </xsl:copy>
       </xsl:when>
-      <xsl:when test='@rnd:style = "emphasis-bold"'>
+      <xsl:when test='@rnd:style = "emphasis-bold" or
+                      @rnd:style = "emphasis-strong"'>
         <xsl:copy>
           <xsl:attribute name='role'>bold</xsl:attribute>
           <xsl:call-template name='rnd:attributes'/>
                      select='ancestor::dbk:para/following-sibling::*[self::dbk:informaltable or self::dbk:para[dbk:inlinemediaobject and count(*) = 1 and normalize-space() = ""]][1]'/>
 
        <xsl:variable name='caption'
-                     select='ancestor::dbk:para/following-sibling::dbk:para[@rnd:style = "caption"]'/>
+                     select='ancestor::dbk:para/following-sibling::dbk:para[@rnd:style = "caption" or @rnd:style = "Caption"]'/>
 
        <xsl:variable name='metadata'>
          <xsl:apply-templates select='ancestor::dbk:para/following-sibling::*[1]'
     </xsl:choose>
   </xsl:template>
 
-  <xsl:template match='dbk:para[@rnd:style = "caption"]' mode='rnd:caption'>
+  <xsl:template match='dbk:para[@rnd:style = "caption" or @rnd:style = "Caption"]'
+    mode='rnd:caption'>
     <dbk:caption>
       <dbk:para>
        <xsl:apply-templates/>
   <!-- Find the caption associated with this table -->
   <xsl:template name='rnd:table-caption'>
     <xsl:variable name='candidate'
-                 select='following-sibling::dbk:para[@rnd:style = "caption"][1]'/>
+                 select='following-sibling::dbk:para[@rnd:style = "caption" or @rnd:style = "Caption"][1]'/>
 
     <xsl:if test='$candidate != "" and
                  generate-id($candidate/preceding-sibling::dbk:informaltable[1]) = generate-id(.)'>
   <!-- Find table associated text -->
   <xsl:template name='rnd:table-textobject'>
     <xsl:variable name='caption'
-                 select='following-sibling::dbk:para[@rnd:style = "caption"][1]'/>
+                 select='following-sibling::dbk:para[@rnd:style = "caption" or @rnd:style = "Caption"][1]'/>
 
     <xsl:if test='generate-id($caption/preceding-sibling::dbk:informaltable[1]) = generate-id(.)'>
       <xsl:variable name='content'
index d5da84b5af0aa4eb57c085149d9e6416d8c7225f..9ef8daaba4fbb844898968e0ce40130f75af4e28 100644 (file)
   </xsl:template>
 
   <xsl:template match='w:tbl'>
+    <xsl:variable name='tbl.style'
+      select='key("style", w:tblPr/w:tblStyle/@w:val) | .'/>
+
     <xsl:variable name='border.top'>
       <xsl:choose>
-        <xsl:when test='w:tblPr/w:tblBorders/w:top[not(@w:val = "nil" or @w:val = "none")]'>1</xsl:when>
-        <xsl:when test='w:tblPr/w:tblBorders/w:top[@w:val = "nil" or @w:val = "none"]'>0</xsl:when>
+        <xsl:when test='$tbl.style/w:tblPr/w:tblBorders/w:top[not(@w:val = "nil" or @w:val = "none")]'>1</xsl:when>
+        <xsl:when test='$tbl.style/w:tblPr/w:tblBorders/w:top[@w:val = "nil" or @w:val = "none"]'>0</xsl:when>
         <xsl:when test='w:tr[1]/w:tc[w:tcPr/w:tcBorders/w:top[not(@w:val = "nil" or @w:val = "none")]]'>1</xsl:when>
-        <xsl:when test='w:tblPr/w:tblStyle and
-                        key("style", w:tblPr/w:tblStyle/@w:val)/w:tblPr/w:tblBorders/w:top'>1</xsl:when>
         <xsl:otherwise>0</xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
     <xsl:variable name='border.bottom'>
       <xsl:choose>
-        <xsl:when test='w:tblPr/w:tblBorders/w:bottom[not(@w:val = "nil" or @w:val = "none")]'>1</xsl:when>
-        <xsl:when test='w:tblPr/w:tblBorders/w:bottom[@w:val = "nil" or @w:val = "none"]'>0</xsl:when>
+        <xsl:when test='$tbl.style/w:tblPr/w:tblBorders/w:bottom[not(@w:val = "nil" or @w:val = "none")]'>1</xsl:when>
+        <xsl:when test='$tbl.style/w:tblPr/w:tblBorders/w:bottom[@w:val = "nil" or @w:val = "none"]'>0</xsl:when>
         <xsl:when test='w:tr[1]/w:tc[w:tcPr/w:tcBorders/w:bottom[not(@w:val = "nil" or @w:val = "none")]]'>1</xsl:when>
-        <xsl:when test='w:tblPr/w:tblStyle and
-                        key("style", w:tblPr/w:tblStyle/@w:val)/w:tblPr/w:tblBorders/w:bottom'>1</xsl:when>
         <xsl:otherwise>0</xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
     <xsl:variable name='border.left'>
       <xsl:choose>
-        <xsl:when test='w:tblPr/w:tblBorders/w:left[not(@w:val = "nil" or @w:val = "none")]'>1</xsl:when>
-        <xsl:when test='w:tblPr/w:tblBorders/w:left[@w:val = "nil" or @w:val = "none"]'>0</xsl:when>
+        <xsl:when test='$tbl.style/w:tblPr/w:tblBorders/w:left[not(@w:val = "nil" or @w:val = "none")]'>1</xsl:when>
+        <xsl:when test='$tbl.style/w:tblPr/w:tblBorders/w:left[@w:val = "nil" or @w:val = "none"]'>0</xsl:when>
         <xsl:when test='w:tr[1]/w:tc[w:tcPr/w:tcBorders/w:left[not(@w:val = "nil" or @w:val = "none")]]'>1</xsl:when>
-        <xsl:when test='w:tblPr/w:tblStyle and
-                        key("style", w:tblPr/w:tblStyle/@w:val)/w:tblPr/w:tblBorders/w:left'>1</xsl:when>
         <xsl:otherwise>0</xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
     <xsl:variable name='border.right'>
       <xsl:choose>
-        <xsl:when test='w:tblPr/w:tblBorders/w:right[not(@w:val = "nil" or @w:val = "none")]'>1</xsl:when>
-        <xsl:when test='w:tblPr/w:tblBorders/w:right[@w:val = "nil" or @w:val = "none"]'>0</xsl:when>
+        <xsl:when test='$tbl.style/w:tblPr/w:tblBorders/w:right[not(@w:val = "nil" or @w:val = "none")]'>1</xsl:when>
+        <xsl:when test='$tbl.style/w:tblPr/w:tblBorders/w:right[@w:val = "nil" or @w:val = "none"]'>0</xsl:when>
         <xsl:when test='w:tr[1]/w:tc[w:tcPr/w:tcBorders/w:rightt[not(@w:val = "nil" or @w:val = "none")]]'>1</xsl:when>
-        <xsl:when test='w:tblPr/w:tblStyle and
-                        key("style", w:tblPr/w:tblStyle/@w:val)/w:tblPr/w:tblBorders/w:rightt'>1</xsl:when>
         <xsl:otherwise>0</xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
     </dbk:row>
   </xsl:template>
   <xsl:template match='w:tc'>
+    <xsl:variable name='tbl.style'
+      select='ancestor::w:tbl[1] |
+              key("style", ancestor::w:tbl[1]/w:tblPr/w:tblStyle/@w:val)'/>
+
     <dbk:entry>
-      <xsl:if test='ancestor::w:tbl[1]/w:tblPr/w:tblBorders/w:insideH[not(@w:val = "nil" or @w:val = "none")] |
+      <xsl:if test='$tbl.style/w:tblPr/w:tblBorders/w:insideH[not(@w:val = "nil" or @w:val = "none")] |
                     w:tcPr/w:tcBorders/w:bottom[not(@w:val = "nil" or @w:val = "none")]'>
         <xsl:attribute name='rowsep'>1</xsl:attribute>
       </xsl:if>
-      <xsl:if test='ancestor::w:tbl[1]/w:tblPr/w:tblBorders/w:insideV[not(@w:val = "nil" or @w:val = "none")] |
+      <xsl:if test='$tbl.style/w:tblPr/w:tblBorders/w:insideV[not(@w:val = "nil" or @w:val = "none")] |
                     w:tcPr/w:tcBorders/w:right[not(@w:val = "nil" or @w:val = "none")]'>
         <xsl:attribute name='colsep'>1</xsl:attribute>
       </xsl:if>