I have this simple xslt code:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="yes"/>
<xsl:template match="/racine/Requete">
<xsl:for-each select="Row">
<xsl:value-of select="Col[@name = 'Service Point']/." />
<xsl:text>ME02</xsl:text>
<xsl:value-of select="Col[@name = 'Meter Number']/." />
<xsl:value-of select="Col[@name = 'Date']/." />
<xsl:value-of select="translate(Col[@name = 'Import Active kWh']/.,',','.')" />
<xsl:text>30000000000000000000</xsl:text>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The Meter Number parameter can have max 10 alphanumeric. so if for example the value is 232345, I want to display (pad with spaces):' 232345'. I have the same case for Import Active kWh, this is a numeric field fix 12 type numeric, but if the value is 56884, I want to display (pad with 0 at the begining) '000000056884'.
Thanks for your useful help as usual!
Regards.
XSLT has
format-number
function soformat-number(translate(Col[@name = 'Import Active kWh']/.,',','.'), '000000000000')
should solve one problem.For the numeric field you can simply use the
format-number()
function, e.g.:For the alpha-numeric field, try:
If you need to do it more than once, consider re-writing this as a function.
Note: this location step
/.
doesn't do anything.