RolfK said:
can anyone help me with a peace of xslt which converts a
number to a binary or hex string ?
I even can not find a power operator in xslt / xpath 2.0.
Why would you need a power operator? And if you need it, why
not write one yourself?
Anyway,
<xsl:function
xmlns:xs="
http://www.w3.org/2001/XMLSchema"
xmlns:rsl="
http://ranselett.net/xslt2lib"
name="rsl:conv-dec-to-numsys"
as="xs:string">
<xsl
aram name="dec" as="xs:integer"/>
<xsl
aram name="base" as="xs:integer"/>
<xsl:variable name="chr" as="xs:string"
select="'0123456789abcdef'"/>
<xsl:if
test=
"
(1 gt $base) or (string-length($chr) lt $base)
">
<xsl:message terminate="yes">OOPS.</xsl:message>
</xsl:if>
<xsl:variable name="car" as="xs:integer"
select="$dec mod $base"/>
<xsl:variable name="cdr" as="xs:integer"
select="($dec div $base) cast as xs:integer"/>
<xsl:value-of
select=
"
concat
(
if ($base lt $dec)
then rsl:conv-dec-to-numsys($cdr,$base)
else '',
substring($chr,1+$car,1)
)
"/>
</xsl:function>
I have a dark suspicion Dimitre Novatchev already has
something functionally similar but better in that FXSL lib
of his.