XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Pravin TailorSubject: Text file to CSV to xml
Author: Pravin Tailor
Date: 12 Jun 2012 08:13 PM
Hi,

I have a text file with the following separator:

Questions:

1. How do I set this as one of the separator in the drop down list.

2. How can I replace this character with a 'comma'?


Would it be better to convert to csv first and then to xml or can I go directly to xml by using '' as the field separator when creating a convert file?

Many thanks.
Pravin

Postnext
Ivan PedruzziSubject: Text file to CSV to xml
Author: Ivan Pedruzzi
Date: 13 Jun 2012 01:20 AM

I would use the built-in CSV converter
http://www.stylusstudio.com/csv_to_xml.html.

To change the separator you can pipe the input document into an identity transformation than pipe-out into the CSV converter using a different separator.

If you share sample of your data we will show you how.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
Pravin TailorSubject: Text file to CSV to xml
Author: Pravin Tailor
Date: 13 Jun 2012 02:13 AM
Hi Ivan,

Here is a test data file.

Thanks.
Pravin


DocumentTestData.txt
Text file for conversion to csv to xml

Postnext
Ivan PedruzziSubject: Text file to CSV to xml
Author: Ivan Pedruzzi
Date: 13 Jun 2012 09:29 AM

Have a look at the solution attached, does it help?

Ivan Pedruzzi
Stylus Studio Team


DocumentflatToFlat.zip

Postnext
Pravin TailorSubject: Text file to CSV to xml
Author: Pravin Tailor
Date: 14 Jun 2012 12:05 AM
Hi Ivan,

That is great.

Are you able to provide me with some explanation on how the porject is set up, how the '' character is setup in the project to be converted to a comma.

I am very new to this conversion procedure and it would help me great deal with some explanation. I have gone through the video on csv to xml conversion and need to look at it again and use the output of this test data to generate xml output.

Thanks again.
Pravin

Postnext
Pravin TailorSubject: Text file to CSV to xml
Author: Pravin Tailor
Date: 14 Jun 2012 01:43 AM
Hi Ivan,

That is great.

Are you able to provide me with some explanation on how the porject is set up, how the '' character is setup in the project to be converted to a comma.

I am very new to this conversion procedure and it would help me great deal with some explanation. I have gone through the video on csv to xml conversion and need to look at it again and use the output of this test data to generate xml output.

Thanks again.
Pravin

Postnext
Ivan PedruzziSubject: Text file to CSV to xml
Author: Ivan Pedruzzi
Date: 14 Jun 2012 10:48 AM

If you open the scenario dialog in the XSLT editor you will find the information pretty self explanatory.

In input the CSV converter takes the flat file and turns into XML

The XSLT processor just pipe the XML into the CSV converter, this time changing the character separator.

Input document URL
converter:CSV:sep=ñ?file:///g:/TestData.txt

Output document URL
converter:CSV:sep=,?file:///g:/out.txt

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
Pravin TailorSubject: Text file to CSV to xml
Author: Pravin Tailor
Date: 17 Jun 2012 09:08 PM
Originally Posted: 17 Jun 2012 08:17 PM
Hi Ivan,

Many thanks for the explanation.

I have one question and that is, how or why is the character in the original file converted to ñ in the converter? Is this some kind of character translation? If so, what is this conversion?

Are there expamples of these on your website?

Thanks.
Pravin

Posttop
Ivan PedruzziSubject: Text file to CSV to xml
Author: Ivan Pedruzzi
Date: 18 Jun 2012 11:14 AM

The character is made of multiple bytes, in order to encode it into a valid URL you have to escape it.

XPath 2.0 provides a function to escape special characters for URL

fn:escape-html-uri("converter:CSV:sep=?file:///TestData.txt")

the resulting URL is

converter:CSV:sep=%C3%B1?file:///TestData.txt

Once the URL is in the scenario it may get escaped so you get

converter:CSV:sep=ñ?file:///g:/TestData.txt

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.