I am transforming XML to .CSV with XSLT, I have few employee id’s which start with zeros and when xslt is converting file to .csv format leading zeros are getting stripped off. Is there anyway that we can prevent leading zeros getting stripped off when XSLT is converting file from XML to .csv?
Following is my xml input
<wd:Report_Data xmlns:wd="urn:com.workday.report/Demograhics_Report">
<wd:Report_Entry>
<wd:Flag>Active_Employee</wd:Flag>
<wd:Employeeid>00012345</wd:Employeeid>
<wd:FirstName>Jack</wd:FirstName>
<wd:LastName>Jones</wd:LastName>
<wd:businessTitle>Service Assistant</wd:businessTitle>
</wd:Report_Entry>
<wd:Report_Entry>
<wd:Flag>Inactive_Employee</wd:Flag>
<wd:Userid>00012355</wd:Userid>
<wd:FirstName>Maddy</wd:FirstName>
<wd:LastName>Bolt</wd:LastName>
<wd:businessTitle>Service Assistant</wd:businessTitle>
</wd:Report_Entry>
I have tried with the following XSLT.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
xmlns:xtt="urn:com.workday/xtt"
xmlns:wd="urn:com.workday.report/Demograhics_Report"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
<xsl:variable name="linefeed" select="'
'"/>
<xsl:template match="wd:Report_Data">
<File>
<xsl:text>"EMPLOYEE ID"</xsl:text>
<xsl:value-of select="$linefeed"/>
<!-- for each Employee section -->
<xsl:for-each select="/wd:Report_Data/wd:Report_Entry">
<xsl:if test="wd:Flag ='Active_Employee'">
<xsl:text>"</xsl:text>
<xsl:value-of select="concat('','"',wd:Employeeid)"/>
<xsl:text>"</xsl:text>
<xsl:value-of select="$linefeed"/>
</xsl:if>
</xsl:for-each>
</File>
</xsl:template>
</xsl:stylesheet>
If employee id is 00012345, with the above line in XSLT, return value was 00012345”. Is there anyway that makes the value to be returned as 00012345 without any quotes or any special characters?
Thanks, Jithen.