View Full Version : double line breaks in xslt csv export!!

12-17-2008, 11:08 PM
Hey all:

A very simple xslt file here that I'm using to export FileMaker data into a csv file. Works great, but it puts in two line breaks after each row. So when I pull it into excel, I have values on every other row, with a blank in between. Can't figure it out to save my life. Here's the code:

<?xml version="1.0" encoding="utf-8"?>
version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<xsl:output method="text" version="1.0" encoding="utf-8" indent="no" />
<xsl:template match="/">
<!-- Header line, inserted only once; if not desired, remove -->
All of my column headers here ...

<xsl:for-each select="fm:FMPXMLRESULT/fm:RESULTSET/fm:ROW">
<xsl:for-each select="fm:COL/fm:DATA">
<xsl:variable name="fmdata">
<xsl:value-of select="."/>
<xsl:variable name="newData">
<xsl:when test="contains( $fmdata, '&quot;' )">

<xsl:call-template name="escape_quotes">
<xsl:with-param name="string" select="$fmdata" />
<xsl:otherwise><xsl:value-of select="$fmdata"/></xsl:otherwise>

<xsl:variable name="newval">
<xsl:value-of select="translate($newData, '&#xA;', '')"/>

<xsl:value-of select="concat('&#x22;', $newval, '&#x22;')" />
<xsl:if test="position() != last()"><xsl:text>,</xsl:text></xsl:if>
<xsl:variable name="thissheet">
<xsl:value-of select="." />

<xsl:template name="escape_quotes">
<xsl:param name="string" />

<xsl:value-of select="substring-before( $string, '&quot;' )" />
<xsl:variable name="substring_after_first_quote" select="substring-after( $string, '&quot;' )" />
<xsl:when test="not( contains( $substring_after_first_quote, '&quot;' ) )">
<xsl:value-of select="$substring_after_first_quote" />
<!-- The substring after the first quote contains a quote.
So, we call ourself recursively to escape the quotes
in the substring after the first quote.
<xsl:call-template name="escape_quotes">
<xsl:with-param name="string" select="$substring_after_first_quote"/>

Any help would be greatly appreciated. Thanks.

12-24-2008, 06:18 PM
Would it be possible to post the source XML file you are using? Also, what tool are using to perform the transformation?

I loaded your XSLT into XMLSpy, and downloaded a sample XML file from the Filemaker site at http://www.filemaker.com/help/12-Import%20export34.html.

The output was what you are expecting - one line of CSV data per line, no extra line-breaks. The only thing I saw out of whack was an extra line feed at the end of the file, resulting in a blank line at the end of the file. Excel didn't seem to mind having that line there.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum