[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

codepoints-to-string failing on spaces

Subject: codepoints-to-string failing on spaces
From: "Spencer Tickner" <spencertickner@xxxxxxxxx>
Date: Wed, 30 Jul 2008 12:06:24 -0700
 codepoints-to-string failing on spaces
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[@type
= $font_type]/char[name[text() = codepoints-to-string($i)]]/wx)
                            )*0.001
                    )
                )"/>
    </xsl:template>

</xsl:stylesheet>


Thanks,

Spencer

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.