Search code examples
xslttransformationworkday-api

How to remove dashes in numbers WITHOUT removing leading zeros


The input (account numbers) I have are currently in the format 005-947864-296, I'm using the translate function to remove dashes as follows: <xsl:value-of select="translate(($account_number), '-', '')"/> The problem is that the output I'm getting in the csv is 5947864296 (which is removing Leading Zeros). How do I remove the dashes WITHOUT removing the leading zeros?

I'm using XSLT 2.0 and I tried both translate and replace functions but getting the same result!


Solution

  • Perhaps you are viewing the generated CSV by loading it into a spreadsheet program such as Microsoft Excel? Excel (notoriously) assumes that if a field is all-numeric, leading zeroes are insignificant and can be discarded (which is not the case for things such as account numbers).

    The problem isn't with your XSLT code generating the CSV, it's with the application you are using to read/process the CSV.