I'm running into an issue with an XSLT Transformation I'm trying to do. In the overall project, I'm working to convert an XML document to a CSV file for a database upload. The problem is the XML sends dates as an attribute value in ISO8601 format (YYYY-MM-DDT00:00:00), but for the database to take it from the CSV file, I need to convert it to MM/DD/YYYY.
Here's an XML Sample:
<GetChanged>
<UserInformation>
<Column Name="id" Value="555555555"/>
<Column Name="name" Value="Kevin"/>
<Column Name="bday" Value="1990-01-01T00:00:00"/>
</UserInformation>
</GetChanged>
Here's the XSLT I'm trying to use:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:csv="csv:csv">
<xsl:output method="text"/>
<xsl:template match="GetChanged">
<!-- header -->
<xsl:text>"id","name","bday" </xsl:text>
<!-- data rows -->
<xsl:for-each select="UserInformation">
<!-- data cells -->
<xsl:for-each select="Column[@Name='id']">
<xsl:text>"</xsl:text>
<xsl:value-of select="@Value"/>
<xsl:text>"</xsl:text>
</xsl:for-each>
<xsl:text>,</xsl:text>
<xsl:for-each select="Column[@Name='name']">
<xsl:text>"</xsl:text>
<xsl:value-of select="@Value"/>
<xsl:text>"</xsl:text>
</xsl:for-each>
<xsl:text>,</xsl:text>
<xsl:for-each select="Column[@Name='bday']">
<xsl:text>"</xsl:text>
<xsl:value-of select="format-date(@Value, '[M01]/[D01]/[Y0001]')"/>
<xsl:text>"</xsl:text>
</xsl:for-each>
<xsl:if test="position()!=last()">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
However, when I run this through Ruby using Nokogiri, I end up getting an error:
RuntimeError: runtime error: element value-of XPath evaluation returned no result
Thoughts on what I can do to format this date appropriately?
Thanks in advance!