tags:

views:

83

answers:

2

Hello

I am using SSIS on SQL Server 2005, VS 2005 SP2.

I have created an XSLT to convert XML to CSV format. When I run this through XML Spy it works fine. I have configured an XML Task within and SSIS package to transform the XML file. Unfortunately, when SSIS performs the transform it does not include the CR/LF at the end of each record - I am left with a sigle line.

I have pased the XSLT below. Could anyone let me know why SSIS is ignoring the ?

I have also pasted a sample XML doc.

Many thanks,

Rob.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
<xsl:output method="text" encoding="utf-8"/>
<xsl:strip-space elements="*"/>
    <xsl:template match="/pptxn">
     <xsl:variable name="fileName" select="/pptxn/file_name"/>
     <xsl:variable name="sendingOrg" select="/pptxn/sending_org"/>
     <xsl:variable name="dateCreated" select="/pptxn/date_created"/>
     <xsl:variable name="timeCreated" select="/pptxn/time_created"/>
     <xsl:variable name="sequenceNumber" select="/pptxn/sequence_number"/>
     <xsl:text>FileName,SendingOrg,DateCreated,TimeCreated,SequenceNumber,PartnerNumber,PartnerOutletRef,CardAccountNumber,TransactionDate,TransactionTime,Spend,PartnerPoints,PartnerReference,PartnerPosId</xsl:text>
    <xsl:text>&#xD;</xsl:text>
     <xsl:for-each select="transaction">
      <xsl:value-of select="$fileName"/>,<xsl:value-of select="$sendingOrg"/>,<xsl:value-of select="$dateCreated"/>,<xsl:value-of select="$timeCreated"/>,<xsl:value-of select="$sequenceNumber"/>,<xsl:value-of select="partner_number"/>,<xsl:value-of select="partner_outlet_ref"/>,<xsl:value-of select="card_account_number"/>,<xsl:value-of select="transaction_date"/>,<xsl:value-of select="transaction_time"/>,<xsl:value-of select="spend"/>,<xsl:value-of select="partner_points"/>,<xsl:value-of select="partner_reference"/>,<xsl:value-of select="partner_pos_id"/>
      <xsl:text>&#xD;</xsl:text>
     </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Now the XML -->

<?xml version="1.0" encoding="UTF-8"?>
<pptxn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Y:\PartnerPoints\XML\PointsPartnerRequest.xsd">
    <file_name>PPRequest.xml</file_name>
    <sending_org>1</sending_org>
    <date_created>20091121</date_created>
    <time_created>153421</time_created>
    <sequence_number>2</sequence_number>
    <transaction_count>3</transaction_count>
    <transaction>
     <partner_number>1</partner_number>
     <partner_outlet_ref>outlet ref 1</partner_outlet_ref>
     <card_account_number>1</card_account_number>
     <transaction_date>20091221</transaction_date>
     <transaction_time>091256</transaction_time>
     <spend>21.34</spend>
     <partner_points>40</partner_points>
     <partner_reference>shop x1</partner_reference>
     <partner_pos_id>pos id 1</partner_pos_id>
    </transaction>
    <transaction>
     <partner_number>2</partner_number>
     <partner_outlet_ref>outlet ref 2</partner_outlet_ref>
     <card_account_number>2</card_account_number>
     <transaction_date>20091222</transaction_date>
     <transaction_time>091257</transaction_time>
     <spend>21.35</spend>
     <partner_points>41</partner_points>
     <partner_reference>shop x2</partner_reference>
     <partner_pos_id>pos id 2</partner_pos_id>
    </transaction>
     <transaction>
     <partner_number>3</partner_number>
     <partner_outlet_ref>outlet ref 3</partner_outlet_ref>
     <card_account_number>3</card_account_number>
     <transaction_date>20091223</transaction_date>
     <transaction_time>091258</transaction_time>
     <spend>21.36</spend>
     <partner_points>42</partner_points>
     <partner_reference>shop x3</partner_reference>
     <partner_pos_id>pos id 3</partner_pos_id>
    </transaction>
</pptxn>
+2  A: 

You may need to change

<xsl:text>&#xD;</xsl:text>

to

<xsl:text>&#xD;&#xA;</xsl:text>
brianary
Thanks for the suggestion but I'm afraid that had no effect :(
Rob Bowman
What about using just ?
brianary
Nope, that doesn't work either. As a test I also changed the <xsl:text></xsl:text> to <xsl:text>moose</xsl:text>. This was written to the target CSV as expected. It seems that SSIS 2005 just will not output the . I also tried the "ProcessXMLData Sample" from codeplex. This work fine on SSIS 2008. When I copy the code to a new SSIS 2005 package I get the same problem, an output CSV on a single line.
Rob Bowman
A: 

I changed the char code from hex to decimal and now it works on SSIS 2005 :)

<xsl:text>&#13;&#10;</xsl:text>

very strange...

Rob Bowman