Bertrand
Bertrand

Reputation: 601

Modifying values with XSLT

I have XML file with values expressed in SI unit (m, N). I use an XSLT document to transform it into HTML page where I would like to display values with other units (um, mN).

Is there a way to modify values I extract from my XML document using XSLT without modifying XML content before XSLT processing ?

Thanks in advance for your help

Bertrand


Just to notice to others interesting in. I'm developing in Python, and lxml library allow you to call extensions in XSLT.

http://lxml.de/extensions.html

Upvotes: 1

Views: 342

Answers (2)

Simon Keep
Simon Keep

Reputation: 10022

If you were using c# to run the xslt transform, and the maths capabilities of Xpath are not good enough for your requirements, you can make calls from the xslt to methods in your c# class which would allow you to call out to c# to do your maths and then return the value back into your xslt. Search for c# xslt extensions.

Upvotes: -1

Tomalak
Tomalak

Reputation: 338386

You can do math in XPath expressions:

<!-- divide somevalue by 1000 --> 
<xsl:value-of select="somevalue div 1000.0" />

Upvotes: 5

Related Questions