Skip to Content

HCI: Need xslt code to convert xml to text.

Dec 18, 2017 at 07:34 AM


avatar image

Hi Experts

Below is my XML after one of my mapping

i need to convert it to text using an xslt code

<?xml version="1.0" encoding="UTF-8"?>
<ns0:FILE xmlns:ns0="http://bc.***.com/FILE">

I want this to be converted like below using xslt.


I need help in writing the xslt code for this one 
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Evgeniy Kolmakov Dec 18, 2017 at 08:45 AM

Hi Naina!

XSLT isn't intended for producing text files from XML input. You could achieve it using java or groovy.

Regards, Evgeniy.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

An XSLT stylesheet can create text output, similar to how it can create XML and HTML. Depending on the transformation, it can even be the best choice. Extracting pieces of data from deep within an XML document is so much easier in XSLT, whereas processing that data to generate text is probably easier in Groovy.


Hi Morten!

Acually I didn't say it couldn't. I just believe that using java, for example, gives you more flexibility and control on desired output.

Regards, Evgeniy.

Morten Wittrock Dec 18, 2017 at 02:58 PM

Hi Naina

You can use the xsl:output element to indicate the type of output. Here's a small stylesheet that generates the text string you need:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="" xmlns:ns0="http://bc.***.com/FILE">
    <xsl:output method="text"/>
    <xsl:template match="/">
        <xsl:value-of select="/ns0:FILE/ACCOUNT_ID"/>
        <xsl:value-of select="/ns0:FILE/CURRENCY"/>
        <xsl:value-of select="/ns0:FILE/BRANCH_ID"/>
        <xsl:value-of select="/ns0:FILE/TRANSACTION_TYPE"/>
        <xsl:value-of select="/ns0:FILE/AMOUNT"/>
        <xsl:value-of select="/ns0:FILE/PARTICULARS"/>



10 |10000 characters needed characters left characters exceeded
Apu Das Jan 05 at 01:53 PM

Hi Naina,

This can be achieved using available standard pallet. You can achieve this like below, no need to go for XSLT mapping.

1. Use a message mapping to convert your structure like below. Simple concatenate function available in Graphical mapping is enough to achieve this.

<?xml version="1.0" encoding="UTF-8"?>

2. After this step, use XML to CSV converter -

Path to Source Element in XSD: //Record

Field Separator in CSV: tab



10 |10000 characters needed characters left characters exceeded