summaryrefslogtreecommitdiff
path: root/xhtml5/html5-element-mods.xsl
diff options
context:
space:
mode:
Diffstat (limited to 'xhtml5/html5-element-mods.xsl')
-rw-r--r--xhtml5/html5-element-mods.xsl37
1 files changed, 27 insertions, 10 deletions
diff --git a/xhtml5/html5-element-mods.xsl b/xhtml5/html5-element-mods.xsl
index 9aae285..f3cb2d1 100644
--- a/xhtml5/html5-element-mods.xsl
+++ b/xhtml5/html5-element-mods.xsl
@@ -336,16 +336,25 @@
<!-- HTML5: converts obsolete HTML attributes to CSS styles -->
<xsl:template match="*" mode="convert.to.style">
+ <xsl:variable name="element" select="local-name(.)"/>
+
<xsl:variable name="style.from.atts">
<xsl:for-each select="@*">
<xsl:choose>
- <xsl:when test="local-name() = 'width'">
+ <!-- width and height attributes are ok for img element -->
+ <xsl:when test="local-name() = 'width' and $element != 'img'">
<xsl:text>width: </xsl:text>
<xsl:value-of select="."/>
<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:text>; </xsl:text>
+ </xsl:when>
+
<xsl:when test="local-name() = 'align'">
<xsl:text>text-align: </xsl:text>
<xsl:value-of select="."/>
@@ -395,15 +404,23 @@
<xsl:value-of select="$style"/>
</xsl:attribute>
</xsl:if>
- <!-- Also skip disallowed summary attributes -->
- <xsl:copy-of select="@*[local-name(.) != 'width' and
- local-name(.) != 'summary' and
- local-name(.) != 'border' and
- local-name(.) != 'cellspacing' and
- local-name(.) != 'cellpadding' and
- local-name(.) != 'style' and
- local-name(.) != 'align' and
- local-name(.) != 'valign']"/>
+ <!-- skip converted atts, and also skip disallowed summary attribute -->
+ <xsl:for-each select="@*">
+ <xsl:choose>
+ <xsl:when test="local-name(.) = 'width' and $element != 'img'"/>
+ <xsl:when test="local-name(.) = 'height' and $element != 'img'"/>
+ <xsl:when test="local-name(.) = 'summary'"/>
+ <xsl:when test="local-name(.) = 'border'"/>
+ <xsl:when test="local-name(.) = 'cellspacing'"/>
+ <xsl:when test="local-name(.) = 'cellpadding'"/>
+ <xsl:when test="local-name(.) = 'style'"/>
+ <xsl:when test="local-name(.) = 'align'"/>
+ <xsl:when test="local-name(.) = 'valign'"/>
+ <xsl:otherwise>
+ <xsl:copy-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
<xsl:apply-templates mode="convert.to.style"/>
</xsl:element>
</xsl:template>