Topic
3 replies Latest Post - ‏2013-03-20T14:31:28Z by SystemAdmin
SystemAdmin
SystemAdmin
1250 Posts
ACCEPTED ANSWER

Pinned topic Header Row on Flat File

‏2009-06-09T19:28:45Z |
I have succesfully created an orchestration that extracts data fom Salesforce.com, writes it to a csv file and emails the file to a user.  However,  I want to put a header row on the file.  How can I create a header row that will show the column headings.
 
Thanks
Mike Viola
Updated on 2013-03-20T14:31:28Z at 2013-03-20T14:31:28Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1250 Posts
    ACCEPTED ANSWER

    Resolved

    ‏2009-06-10T14:28:18Z  in response to SystemAdmin

    I resolved the issue.  You create a header section of the file schema.  Do not map anything to that section and define a default value for the nodes.

    • SystemAdmin
      SystemAdmin
      1250 Posts
      ACCEPTED ANSWER

      Re: Resolved

      ‏2013-03-20T14:11:01Z  in response to SystemAdmin
      Hi Is there any other direct way of handling the issue! Providing defaults solves the purpose but is cumbersome if you have large number of columns...
      The other way I though was to read column names as a data from another flat file and pass it along...however, the method does not look clean.
      • SystemAdmin
        SystemAdmin
        1250 Posts
        ACCEPTED ANSWER

        Re: Resolved

        ‏2013-03-20T14:31:28Z  in response to SystemAdmin
        A XSLT stylesheet may be used to do the conversion.

        I define a target XML document since our XSLT is for XML to XML conversion) with root node 'start' and a single field 'string'.
        Schema for target document:
        <!--
        <?xml version="1.0" encoding="UTF-8"?>
        <xs:schema elementFormDefault = "qualified" xmlns:xs = "http://www.w3.org/2001/XMLSchema">
        <xs:element name = "start">
        <xs:complexType>
        <xs:sequence>
        <xs:element ref = "string"/>
        </xs:sequence>
        </xs:complexType>
        </xs:element>
        <xs:element name = "string" type = "xs:string"/>
        </xs:schema>
        -->

        The stylesheet can be used to convert the results of any database query to a CSV file with a header based on the field names.
        <!-- produce comma separated values output -->
        <!-- follow all except last value by comma -->
        <!-- if value contains a comma, enclose it in double quotes -->
        <!--
        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" omit-xml-declaration="yes" media-type="string"/>
        <xsl:template match="/rows">
        <xsl:element name="start">
        <xsl:element name="string">
        <xsl:for-each select="./row">
        <xsl:for-each select="./*">
        <xsl:choose>
        <xsl:when test="contains(current(),',')">"<xsl:value-of select="."/>"</xsl:when>
        <xsl:otherwise>
        <xsl:value-of select="."/>
        </xsl:otherwise>
        </xsl:choose>
        <xsl:if test="position()!=last()">,</xsl:if>
        </xsl:for-each>
        <xsl:text>
        </xsl:text>
        </xsl:for-each>
        </xsl:element>
        </xsl:element>
        </xsl:template>
        </xsl:stylesheet>
        -->