Limit XSLT Variable to single character

183 views Asked by At

Still trying to understand XML & XSLT at the moment. I'm trying to limit the output that the XSLT is getting from the XML, i've seen similar questions but the solutions do not work for this and i am unsure why.

So i have my XSLT:

<xsl:value-of select="format-number(NUMBER,'000000')"/>

My XML:

<NUM>
    <NUMBER>1000</NUMBER>
</NUM>

<NUM>
    <NUMBER>2000</NUMBER>
</NUM>

<NUM>
    <NUMBER>3000</NUMBER>
</NUM>

The code outputs all three "1000", "2000" & "3000", Which is what i get, all above works fine, what i want to change is that the output will be "1", "2" & "3" So i want to say in the code that it will only take the first number from "NUMBER" so the first number of 1000 which would be 1, then 2 from 2000 and 3 from 3000.

I have tried this This but it doesn't work.

1

There are 1 answers

0
Martin Honnen On BEST ANSWER

Based on your comment I think all you need is <xsl:value-of select="substring(NUMBER, 1, 1)"/>.