Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 8th, 2014, 04:08 AM
Authorized User
Join Date: Aug 2013
Posts: 30
Thanks: 9
Thanked 0 Times in 0 Posts
Default meters to centimeters

Can anyone please help me to find out what is the correct way to convert 0.1087 into 10.9 (rounded) that is meters into centimeters in my case?

I have got this in a string value of an attribute, I have put it into a variable x and used the xs:decimal() and format-number() like in the following example:

format-number(xs:decimal($x), '##.####')
I have tried several pictures, but I feel like I am getting something wrong on how this works.

thank you very much
Old May 8th, 2014, 05:01 AM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

First multiply by 100, then round to one place:

round-half-to-even($x * 100, 1)
or if you want to do it with format-number,

format-number($x * 100, '#.0')
Michael Kay
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
pietromaria.liuzzo (May 8th, 2014)

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.