As part of a task at work I'm looking at exporting a simple list of details from a Crystal Report into separate xml files, one for each row.
The list is basic employee info i.e. First name, Surname etc.
Using Crystal Reports 2008 and quickly reading up on XSLT, I've managed to write a transformation that places each employee in it's own element with child-elements detailing its information.
However, i'm trying to use the xsl:result-document command, but Crystal Reports doesn't seem to like it. My XSLT file works fine in SAXON and splits the xml into separate files, but Crystal ignores everything inside the tag completely and just displays the header info.
Has anybody else had a similar problem?
I'm aware that the result-document tag was made available in XSLT 2.0, so would I be right in guessing the processor in Crystal Reports 2008 only works with XSLT 1.0? If so is there a way I can force it to work with XSLT 2.0?
Thanks for your time, Ben
Below is my XSLT file:
<?xml version='1.0' ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:b="urn:crystal-reports:schemas:report-detail">
<xsl:template match="/b:CrystalReport">
<Report>
<xsl:for-each select="b:Details">
<xsl:variable name="empnumber" select="b:Section/b:Field[@Name='EmployeeNumber1']/b:Value"/>
<xsl:result-document href="{$empnumber}.xml">
<Employee>
<xsl:attribute name="ID">
<xsl:value-of select="b:Section/b:Field[@Name='EmployeeNumber1']/b:Value"/>
</xsl:attribute>
<FirstName>
<xsl:value-of select="b:Section/b:Field[@Name='FirstName1']/b:Value"/>
</FirstName>
<Surname>
<xsl:value-of select="b:Section/b:Field[@Name='Surname1']/b:Value"/>
</Surname>
<Test>
<xsl:value-of select="$empnumber" />
</Test>
</Employee>
</xsl:result-document>
</xsl:for-each>
</Report>
</xsl:template>
</xsl:stylesheet>