0

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.

evilsoldier
  • 161
  • 12
  • 1
    The question is not clear and the example is ambiguous. What do you want the result be when the given quantity is 1.6? Note that `xsl:value-of` **always** outputs a *text node* - not an *integer* or any other data type. – michael.hor257k Jul 28 '17 at 17:22
  • It is quantity of items.. it cannot be decimal value. You cannot buy 1.6 quantity of PC for example. That is why I want to remove the decimal part from it and select it as integer :) – evilsoldier Jul 29 '17 at 13:56
  • "*I want to remove the decimal part from it and select it as integer*" Those are two separate things. They just happen to coincide in your example. – michael.hor257k Jul 29 '17 at 15:26
  • Yes, maybe you are right about this. Thank you for the comment, i wll have it in mind for my future questions.. – evilsoldier Jul 30 '17 at 08:24

1 Answers1

1

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

<xsl:value-of select="format-number(@quantity, '#')" />
zx485
  • 28,498
  • 28
  • 50
  • 59