Search code examples
xmlxsltselectattributesvalue-of

XSL select value of xml attribute as integer


i am trying to select some xml attributes from decimal values to integers. For example

<ItemIn quantity="1.0">

The value of @quantity must be selected as integer i.e. only 1.

I am using

<xsl:value-of select="@quantity">

Is there a way to select quantity as integer i.e. as 1 ?

Thanks.


Solution

  • Use the XSLT format-number() Function with a single # as format like this:

    <xsl:value-of select="format-number(@quantity, '#')" />