Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 6th, 2007, 07:36 PM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSL transformation - PIPE delimited to CSV

Hi All,

I am new to XSL transformations. I had gone through some tutorials and most of them talk about XSLT transformations applying on XML file.

My requirement here is transforming a .txt which has PIPE delimited values to same file with COMMA as the delimiter. i.e need to replace all PIPEs with COMMAs

For ex:

From -> 1|ABC|XYZ|123|GOOD
         2|SDF|WEW|432|BAD

To -> 1,ABC,XYZ,123,GOOD
          2,SDF,WEW,432,BAD

Thanks for your help in advance.

~Satish



 
Old June 7th, 2007, 03:09 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

XSLT is a transformation language designed for manipulating XML. You could do this problem in XSLT but I can't see why you would want to: there are other languages such as Perl which seem much better suited to the task.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 10th, 2007, 11:54 PM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your time and suggestion Michael.

Actually we have got a new interface recently, for this we receive files in PIPE delimited. The current process supports only XSLT as pre-process step, that is the only reason I am thinking about XSLT.

Regards,
Satish

 
Old June 11th, 2007, 10:21 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In XSLT 2.0 it's easy enough to read a text file using unparsed-text() and to parse its structure using xsl:analyze-string; it's also easy to write text output using the text output method.

But there's something very odd about this. It makes sense to build a processing pipeline in which the data is passed around as XML and processed using XSLT. It seems very peculiar to design the pipeline around XSLT and then push non-XML data through it.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl transformation ... rajesh_css XSLT 5 September 30th, 2008 12:37 AM
pipe delimited file to SQL using DTS juvesaurabh SQL Server DTS 1 February 16th, 2006 12:56 AM
Foxpro: dbf to pipe delimited text file problem freddellosa Other Programming Languages 0 December 7th, 2005 08:55 PM
Nested XML to CSV transformation 2Poc XSLT 2 September 19th, 2005 03:11 AM
XSL transformation Thodoris XML 0 May 20th, 2004 08:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.