Scenario - How to do convertion of XML to .txt or CSV file using TIBCO-BW ?

If we got an XML file and from this xml ,How can print only its content (tag values) as text string and send this content to specific address using mail.

This Requirement can achieve in TIBCO BW process using this below activities

1. If we have xml file then use Read File activity to get xml string.

2. This XML String is passed to XSLT Style sheet in a XML Transform pallete.

3. In XLST file, Output method is defined as "text", hence output data obtained is of "text" i.e. it will not contain any HTML tags.

4. Then a Write File activity is called, and the output of XML Transform is passed as 'text Content', hence the CSV/txt file gets generated of type like

DATA-1.1 , DATA-1.2 , DATA-1.3
DATA-2.1 , DATA-2.2 , DATA-2.3


5. Later Send Mail activity is called, here at Input tab, File Name is selected under mimeHeader, File Name is given as file created in previous step.

Example XML file and style sheet for the above scenario testing given below.

Here given xml ,Just save this xml as file and use Read File activity to get into BW.

Also here given style sheet ,Use this to configure XSLT file (shared Resource) for Transform XML activity.

-------------------------------------------------------------------
  <employee_list>
    <employee>
        <name>George</name>
        <dept>HR</dept>
        <phone>044-123-4567</phone>
        <email>ex@example.com</email>
    </employee>
    <employee>
        <name>Jones</name>
        <dept>Sales</dept>
        <phone>011-122-2233</phone>
        <email>axe@example.com</email>
    </employee>
    <employee>
        <name>Taylor</name>
        <dept>Engineering</dept>
        <phone>040-111-2333</phone>
        <email>abc@example.com</email>
    </employee>
</employee_list>
 
-------------------------------------------------------------------

Example stylesheet for the conversion of XML to Text string

-------------------------------------------------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="text" />
 <xsl:template match="/">
  <xsl:apply-templates />
  </xsl:template>
 <xsl:template match="employee_list">
  employee Directory for example.com
  <xsl:apply-templates />
  </xsl:template>
<xsl:template match="name">
  Name:
  <xsl:apply-templates />
  </xsl:template>
 <xsl:template match="dept">
  Dept:
  <xsl:apply-templates />
  </xsl:template>
 <xsl:template match="phone">
  Phone:
  <xsl:apply-templates />
  </xsl:template>
 <xsl:template match="email">
  Email:
  <xsl:apply-templates />
  </xsl:template>
  </xsl:stylesheet>

-------------------------------------------------------------------


  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP