Dorel Pureca Dorel Pureca - 3 years ago 109
SQL Question

Create a CSV from a SQL query using XSL

I need help to create a CSV file based on a SQL query.

This is how the current XSL looks like:

<xsl:stylesheet version="1.0"
<xsl:output method="text" encoding="iso-8859-1"/>
<xsl:param name="fieldNames" select="'yes'" />
<xsl:template match="NewDataSet">
<xsl:apply-templates select="Table"/>
<xsl:template match="Table">
<xsl:for-each select="*">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:value-of select="','"/>

Everything works fine, except the fact that I need to add a header row in the CSV with predefined values for each value. How can I do that?

This is how it looks now: enter image description here

This is how I want the CSV to look like: enter image description here

Answer Source

Add e.g.

<xsl:template match="/">

where foo,bar,baz would be your column names.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download