I am trying to convert my xml input to csv output as below details
INPUT file:
<Customer>
<item>
<CustomerID>100000069</CustomerID>
<CustomerGroup>EX</CustomerGroup>
<CustomerName>Test Mehmet</CustomerName>
<CustomerStreet>Street</CustomerStreet>
<HouseNumber>123</HouseNumber>
<CustomerCity>Ismaning</CustomerCity>
<CustomerZip></CustomerZip>
<CustomerCountry>DE</CustomerCountry>
</item>
</Customer>
XSL:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:variable name='newline'>
<xsl:text>
</xsl:text>
</xsl:variable>
<xsl:template match="/Customer">
<xsl:value-of select="concat('"CustomerID";"CustomerGroup";"CustomerName";"CustomerStreet";"HouseNumber";"CustomerCity";"CustomerZIP";"CustomerCountry"',$newline)"/>
<xsl:for-each select="./item">
<xsl:value-of select="concat('"',./CustomerID,'";"',./CustomerGroup,'";"',./CustomerName,'";"',./CustomerStreet,'";"',./HouseNumber,'";"',./CustomerCity,'";"',./CustomerZIP,'";"',./CustomerCountry,'"',$newline)"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
My Original output:
"CustomerID";"CustomerGroup";"CustomerName";"CustomerStreet";"HouseNumber";"CustomerCity";"CustomerZIP";"CustomerCountry" "100000069";"EX";"Test Mehmet";"Street";"123";"Ismaning";"";"DE"
Expected Output:
I need to change all empty values by 'null'. below is my expected output.
"CustomerID";"CustomerGroup";"CustomerName";"CustomerStreet";"HouseNumber";"CustomerCity";"CustomerZIP";"CustomerCountry" "100000069";"EX";"Test Mehmet";"Street";"123";"Ismaning";null;"DE"
Please suggest the additional change required to my code so it will populate null wherever "" comes.