]> granicus.if.org Git - docbook-dsssl/commitdiff
Add px units to some attributes in
authorBob Stayton <bobs@sagehill.net>
Tue, 11 Nov 2014 17:36:27 +0000 (17:36 +0000)
committerBob Stayton <bobs@sagehill.net>
Tue, 11 Nov 2014 17:36:27 +0000 (17:36 +0000)
convert.to.styles template for CSS compatibility.

xsl/xhtml5/html5-element-mods.xsl

index f3cb2d128b7162554e7b5b2e3e7cb7bfbad8a38d..b9a89dc4fffb6ff3fd161386f2333ed1bf3a2414 100644 (file)
       <xsl:choose>
         <!-- width and height attributes are ok for img element -->
         <xsl:when test="local-name() = 'width' and $element != 'img'">
+          <xsl:variable name="attvalue" select="normalize-space(.)"/>
           <xsl:text>width: </xsl:text>
-          <xsl:value-of select="."/>
+          <xsl:value-of select="$attvalue"/>
+          <!-- if integer value, add px unit -->
+          <xsl:if test="floor($attvalue) = $attvalue">
+            <xsl:text>px</xsl:text>
+          </xsl:if>
           <xsl:text>; </xsl:text>
         </xsl:when>
 
         <xsl:when test="local-name() = 'height' and $element != 'img'">
-          <xsl:text>height </xsl:text>
-          <xsl:value-of select="."/>
+          <xsl:variable name="attvalue" select="normalize-space(.)"/>
+          <xsl:text>height: </xsl:text>
+          <xsl:value-of select="$attvalue"/>
+          <!-- if integer value, add px unit -->
+          <xsl:if test="floor($attvalue) = $attvalue">
+            <xsl:text>px</xsl:text>
+          </xsl:if>
           <xsl:text>; </xsl:text>
         </xsl:when>
 
         <xsl:when test="local-name() = 'cellspacing'">
           <xsl:text>border-spacing: </xsl:text>
           <xsl:value-of select="."/>
+          <xsl:text>px</xsl:text>
           <xsl:text>; </xsl:text>
         </xsl:when>
 
         <xsl:when test="local-name() = 'cellpadding'">
           <xsl:text>padding: </xsl:text>
           <xsl:value-of select="."/>
+          <xsl:text>px</xsl:text>
           <xsl:text>; </xsl:text>
         </xsl:when>
       </xsl:choose>