Something like a format-number-hex() function perhaps?
Dave Lowndes
It should be possible to implement a named template to perform the
conversion
<URL:http://www.google.de/search?hl=en&q=XSLT+decimal+to+hex+conversion&btnG=Google+Search&meta=>.
Or use an extension function.
Which XSLT processor are you targetting?
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Ah, something like this maybe?:
http://www.stylusstudio.com/xsllist/200303/post80360.html
>Or use an extension function.
>Which XSLT processor are you targetting?
I'm currently using the MS .Net XSLT facilities but I'm considering
switching to another engine for V2 facilities.
Dave
>> Or use an extension function.
>> Which XSLT processor are you targetting?
>
> I'm currently using the MS .Net XSLT facilities
You could use an extension function then implemented in C# e.g.
<msxsl:script implements-prefix="mf" language="C#">
public string toHex (double n)
{
return ((int)n).ToString("X");
}
</msxsl:script>
<xsl:template match="some-element"
xmlns:mf="http://example.com/2008/functions">
<xsl:value-of select="mf:toHex(number(.))"/>
</xsl:template>
That's the first I've ever heard of such things - that looks much more
elegant :) - I'll give that a go.
I'm considering using a different XSLT processor because of a bug
(https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=314173).
Is there an elegant way of doing the hex output in XSLT 2?
Dave
> Is there an elegant way of doing the hex output in XSLT 2?
Instead of using a named template and xsl:call-template in XSLT 1.0 you
can write a named function in XSLT 2.0 and call it with XPath function
call syntax everywhere you need it.
Thanks once again for all the help Martin.
I've tried the named template & the C# script methods, and I'll go
with the C# script for now as it provides better (easy) control over
the formatting (the result looks better presented with 8 fixed
characters - "X8").
Cheers
Dave