Open bartneck opened 6 months ago
This is as simple as writing
Or like this:
It is also possible to use string format-number(number,format,[decimalformat])
It would be useful to have a global parameter so that we do not have to duplicate the whole XSLT file for roman numerals.
The format="I" only works for xsl:numbers. The format-number() function does not include the option for "I". It is possible to create a new function (below). Would this interfere with the layout calculations? The number 10 would no longer have two digits, but just on: X.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:num="http://example.com/num"
exclude-result-prefixes="num"
version="3.0">
<xsl:function name="num:roman" as="xs:string">
<xsl:param name="value" as="xs:integer"/>
<xsl:number value="$value" format="i"/>
</xsl:function>
<!-- Example usage -->
<xsl:template match="/">
<output>
<xsl:value-of select="num:roman(100)"/>
</output>
</xsl:template>
</xsl:stylesheet>
Using this function on pool length produces the right results, but when trying it for the lengthAsDistance we get an error message:
<xsl:value-of select="../ancestor-or-self::*[sw:lengthAsDistance]"/>
or
<xsl:value-of select="sw:numroman(sw:lengthAsDistance)"/>
Gives this error message:
An empty sequence is not allowed as the first argument of sw:numroman()
find a way to express any numbers as roman numeral