<!-- 72 dpi is 72 px/inch /25.4 is 2.8346 px/mm. w is for 100 chars, so conversion factor is .028346 px/w -->
<xsl:variable name="cf"><xsl:value-of select="number(72 div 2540)"/></xsl:variable>
<!-- varname integer part is measured width in mm for 100 bold characters in each group -->
<xsl:variable name="c74"><xsl:value-of select="string-length(translate(text(),translate(text(),'''',''),''))"/></xsl:variable>
<xsl:variable name="c86"><xsl:value-of select="string-length(translate(text(),translate(text(),',./I\ijl|',''),''))"/></xsl:variable>
<xsl:variable name="c103"><xsl:value-of select="string-length(translate(text(),translate(text(),' !()-:;[]`ft',''),''))"/></xsl:variable>
<xsl:variable name="c120"><xsl:value-of select="string-length(translate(text(),translate(text(),'*r{}',''),''))"/></xsl:variable>
<xsl:variable name="c145"><xsl:value-of select="string-length(translate(text(),translate(text(),'"',''),''))"/></xsl:variable>
<xsl:variable name="c154"><xsl:value-of select="string-length(translate(text(),translate(text(),'z',''),''))"/></xsl:variable>
<xsl:variable name="c170"><xsl:value-of select="string-length(translate(text(),translate(text(),'#$0123456789J_@aceksvxy',''),''))"/></xsl:variable>
<xsl:variable name="c179"><xsl:value-of select="string-length(translate(text(),translate(text(),'+<=>^~',''),''))"/></xsl:variable>
<xsl:variable name="c187"><xsl:value-of select="string-length(translate(text(),translate(text(),'?FLTZbdghnopqu',''),''))"/></xsl:variable>
<xsl:variable name="c204"><xsl:value-of select="string-length(translate(text(),translate(text(),'EPSVXY',''),''))"/></xsl:variable>
<xsl:variable name="c221"><xsl:value-of select="string-length(translate(text(),translate(text(),'&ABCDHKNRU',''),''))"/></xsl:variable>
<xsl:variable name="c238"><xsl:value-of select="string-length(translate(text(),translate(text(),'GOQw',''),''))"/></xsl:variable>
<xsl:variable name="c255"><xsl:value-of select="string-length(translate(text(),translate(text(),'M',''),''))"/></xsl:variable>
<xsl:variable name="c272"><xsl:value-of select="string-length(translate(text(),translate(text(),'%m',''),''))"/></xsl:variable>
<xsl:variable name="c289"><xsl:value-of select="string-length(translate(text(),translate(text(),'W',''),''))"/></xsl:variable>
<xsl:variable name="c298"><xsl:value-of select="string-length(translate(text(),translate(text(),'@',''),''))"/></xsl:variable>
<xsl:variable name="counted"><xsl:value-of select="$c74+$c86+$c103+$c120+$c145+$c154+$c170+$c179+$c187+$c204+$c221+$c238+$c255+$c272+$c289+$c298"/></xsl:variable>
<xsl:variable name="uncounted"><xsl:value-of select="string-length(text())-$counted"/></xsl:variable>
<xsl:variable name="sum">
<xsl:value-of select="74*$c74+86*$c86+103*$c103+120*$c120+145*$c145+154*$c154+170*$c170+179*$c179+187*$c187+204*$c204+221*$c221+238*$c238+255*$c255+272*$c272+289*$c289+298*$c298"/>
</xsl:variable>
<!-- Use generous average width of 204 for all other characters for now -->
<xsl:variable name="cellHeight"><xsl:value-of select="ceiling($cf * ($sum + 204*$uncounted))"/></xsl:variable>
<!-- Simple sanity-check height just assumes 7 pixels per character. -->
<xsl:variable name="cellHeight0"><xsl:value-of select="number(7*string-length(text()))"/></xsl:variable>
<xsl:variable name="debug">
<xsl:value-of select="concat('h0=', $cellHeight0, 'h=', $cellHeight, 'u=', $uncounted, 'c=', $counted, 'cn= ', $c74, ',', $c86, ',', $c103, ',', $c120, ',', $c145, ',', $c154, ',', $c170, ',', $c179, ',', $c187, ',', $c204, ',', $c221, ',', $c238, ',', $c255, ',', $c272, ',', $c289, ',', $c298)"/>
</xsl:variable>
<xsl:variable name="nada"/>
<xsl:element name="fo:block-container">
<xsl:attribute name="reference-orientation">90</xsl:attribute>
<xsl:attribute name="width"><xsl:value-of select="concat($cellHeight, 'px')"/></xsl:attribute>