I calculating character size to get some nice hanging indents in FO.
However my template is failing on spaces and I can't for the life of
me figure out why. I suspected it was codepoints (to or from string)
but when I pull the xPath expressions out of the stylesheet they work
fine. Anyway any advice would be appreciated (processor Saxon 9.0.0.2
that ships with Stylus).
<?xml version='1.0'?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="font_table">
<root>
<charSet type="Times">
<char code="32"><name>
</name><wx>250</wx><llx>0</llx><lly>0</lly><urx>0</urx><ury>0</ury></char>
<char
code="49"><name>1</name><wx>500</wx><llx>111</llx><lly>0</lly><urx>394</urx><ury>676</ury></char>
<char
code="65"><name>A</name><wx>722</wx><llx>15</llx><lly>0</lly><urx>706</urx><ury>674</ury></char>
</charSet>
</root>
</xsl:variable>
<xsl:template match="/">
Works -
<xsl:call-template name="getCharSize">
<xsl:with-param name="font_size">30</xsl:with-param>
<xsl:with-param name="text">A1</xsl:with-param>
</xsl:call-template>
Doesn't -
<xsl:call-template name="getCharSize">
<xsl:with-param name="font_size">30</xsl:with-param>
<xsl:with-param name="text">A 1</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="getCharSize">
<xsl:param name="text" select="''"/>
<xsl:param name="font_size" select="0"/>
<xsl:param name="font_type">Times</xsl:param>
<xsl:value-of select="
sum(
for $i in string-to-codepoints($text) return
(
$font_size *
(
number($font_table/root/charSet[(_at_)type
= $font_type]/char[name[text() = codepoints-to-string($i)]]/wx)
)*0.001
)
)"/>
</xsl:template>
</xsl:stylesheet>
Thanks,
Spencer
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--