6 Replies Latest reply on Jul 6, 2009 8:04 AM by Ravi Kiran Venkatanaranaya

    Problem in XML to CSV transformation

    neha2911 Newbie

      I am exploring jboss-soa-p.4.2.0. I am facing a problem with XML to CSV transformation.
      Smooks does not give any direct way of XML to CSV transformation.So I have tried this transformation using XSLT but it is not working as desired.

      The trouble is it is not working when I am running this with jboss-soa-p.4.2.0 which uses Smooks 0.9. This works correctly with Smooks 1.0 used in later versions of Jboss ESB .

      In the result with Smooks 0.9, i am getting the desired csv within the root element "AssignedTaskDetails".

      My input xml is :

      <xml version="1.0"?>
      <AssignedTaskDetails>
       <task>
       <TaskId>641f71c1</TaskId>
       <TaskDescription>Javatesting</TaskDescription>
       <TaskCompletionTime> EOD</TaskCompletionTime>
       <TaskresponseDetails>ok</TaskresponseDetails>
       <isCancelled>false</isCancelled>
       <isCompleted>false</isCompleted>
       </task>
       <task>
       <TaskId>845dfdf0</TaskId>
       <TaskDescription>Javacoding</TaskDescription>
       <TaskCompletionTime>Urgent</TaskCompletionTime>
       <TaskresponseDetails> will do</TaskresponseDetails>
       <isCancelled>false</isCancelled>
       <isCompleted>false</isCompleted>
       </task>
      </AssignedTaskDetails>
      

      The result I obtain is:
      <AssignedTaskDetails>
       641f71c1,Javatesting,EoD,ok,false,false
      
       845dfdf0,Javacoding,Urgent,yps,false,false
      
       </AssignedTaskDetails>


      The smooks config is:
      <?xml version='1.0' encoding='UTF-8'?>
      <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
       <resource-config selector="task">
       <resource>BasicXslTransform.xsl</resource>
       </resource-config>
      </smooks-resource-list>


      My BasicXslTransform is:
      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="text"/>
      <xsl:template match="AssignedTaskDetails">
       <xsl:apply-templates select="task"/>
      </xsl:template>
      <xsl:template match="task">
       <xsl:for-each select="*">
       <xsl:value-of select="."/>
       <xsl:if test="position() != last()">
       <xsl:value-of select="','"/>
       </xsl:if>
       </xsl:for-each>
       <xsl:text> </xsl:text>
      </xsl:template>
      </xsl:stylesheet>


      In smooks-config if I give resource-config selector as "AssignedTaskDetails" then the result is same as the input xml.

      How should i go about this?