<xsl:template name="graphicsAttributes">
<xsl:param name="mode">fo</xsl:param>
<xsl:if test="@width">
<xsl:choose>
<xsl:when test="ends-with(@width,'%')">
<xsl:choose>
<xsl:when test="$mode='fo'">
<xsl:attribute name="content-width">
<xsl:value-of select="@width"/>
</xsl:attribute>
</xsl:when>
<xsl:when test="$mode='latex'">
<xsl:text>width=</xsl:text>
<xsl:value-of select="number(substring-before(@width,'%')) div 100"/>
<xsl:text>\textwidth,</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="width">
<xsl:value-of select="@width"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="w">
<xsl:choose>
<xsl:when test="ends-with(@width,'pt')">
<xsl:value-of select="@width"/>
</xsl:when>
<xsl:when test="ends-with(@width,'px') and $mode='latex'">
<xsl:value-of select="substring-before(@width,'px')"/>
<xsl:text>pt</xsl:text>
</xsl:when>
<xsl:when test="ends-with(@width,'in')">
<xsl:value-of select="@width"/>
</xsl:when>
<xsl:when test="ends-with(@width,'px')">
<xsl:value-of select="@width"/>
</xsl:when>
<xsl:when test="ends-with(@width,'cm')">
<xsl:value-of select="@width"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@width"/>
<xsl:text>pt</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$mode='fo'">
<xsl:attribute name="content-width">
<xsl:value-of select="$w"/>
</xsl:attribute>
</xsl:when>
<xsl:when test="$mode='latex'">
<xsl:text>width=</xsl:text>
<xsl:value-of select="$w"/>
<xsl:text>,</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="@height">
<xsl:choose>
<xsl:when test="ends-with(@height,'%')">
<xsl:choose>
<xsl:when test="$mode='fo'">
<xsl:attribute name="content-height">
<xsl:value-of select="@height"/>
</xsl:attribute>
</xsl:when>
<xsl:when test="$mode='latex'">
<xsl:text>height=</xsl:text>
<xsl:value-of select="number(substring-before(@height,'%')) div 100"/>
<xsl:text>\textheight,</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="height">
<xsl:value-of select="@height"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="h">
<xsl:choose>
<xsl:when test="ends-with(@height,'pt')">
<xsl:value-of select="@height"/>
</xsl:when>
<xsl:when test="ends-with(@height,'px') and $mode='latex'">
<xsl:value-of select="substring-before(@height,'px')"/>
<xsl:text>pt</xsl:text>
</xsl:when>
<xsl:when test="ends-with(@height,'in')">
<xsl:value-of select="@height"/>
</xsl:when>
<xsl:when test="ends-with(@height,'px')">
<xsl:value-of select="@height"/>
</xsl:when>
<xsl:when test="ends-with(@height,'cm')">
<xsl:value-of select="@height"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@height"/>
<xsl:text>pt</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$mode='fo'">
<xsl:attribute name="content-height">
<xsl:value-of select="$h"/>
</xsl:attribute>
</xsl:when>
<xsl:when test="$mode='latex'">
<xsl:text>height=</xsl:text>
<xsl:value-of select="$h"/>
<xsl:text>,</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:variable name="s">
<xsl:choose>
<xsl:when test="@scale and ends-with(@scale,'%')">
<xsl:value-of select="number(substring-before(@scale,'%')) div 100"/>
</xsl:when>
<xsl:when test="@scale">
<xsl:value-of select="@scale"/>
</xsl:when>
<xsl:when test="not(@width) and not(@height) and not($standardScale=1)">
<xsl:value-of select="$standardScale"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="not($s='')">
<xsl:choose>
<xsl:when test="$mode='fo'">
<xsl:attribute name="scale">
<xsl:value-of select="$s"/>
</xsl:attribute>
</xsl:when>
<xsl:when test="$mode='latex'">
<xsl:text>scale=</xsl:text>
<xsl:value-of select="$s"/>
<xsl:text>,</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:if>
</xsl:template> |