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 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
chris auSubject: how to navigate
Author: chris au
Date: 22 Nov 2005 06:25 AM
Hi,

I am a newbie at XSLT and was wondering whether I could get some hand in regards to the following. I want to use xslt to build a fixed length file

the xml I have looks like this

<?xml version="1.0" encoding="UTF-8"?>
<CSV file="d:\temp\import.csv" fileType="CSV" separator="," type="Structure">
<CSV type="RecordDescriptor">
<ONE fieldType="Integer" format="10" length="10"/>
<TWO fieldType="String" format="6" length="6"/>
</CSV>
<Record>
<ONE type="String">1234567890</ONE>
<TWO type="String">abcdef</TWO>
</Record>
<Record>
<ONE type="String">0987654321</ONE>
<TWO type="String">xyzwyc</TWO>
</Record>
</CSV>

the data i want is under Record elements however the value of the fixed lengths are stored as attributes under the CSV element. This xml is provided to me by some developers I was wondering how I can create fixed length file using the value under record but fixing the length according to the values above

Postnext
(Deleted User) Subject: how to navigate
Author: (Deleted User)
Date: 22 Nov 2005 09:00 AM
Chris,
I think we can cook up something cool for this, but we need to know a few things first.

Is the <CSV type="RecordDescriptor"> element the same each time? That is, do you need to handle just one record format?
Or, maybe there are only 3 or 4 different formats you need to handle?
Or, maybe it is totally variable, and the solution needs to be completely general.
=====
Second, can you clarify what the output format is? Your example seems to imply that the output should be CSV, values separated by comma characters, but you say that you want fixed length. So, do you want fixed length fields with the commas, or just fixed length fields without the commas?
=====
Finally, the data items in your example are already the correct output width. Is that always the case, or do you sometimes need to pad them to the correct length? In the <Record> elements, do all data items always exist, or are there sometimes missing items which need to be replaced by the correct padding?


Thanks
Clyde

Postnext
(Deleted User) Subject: how to navigate
Author: (Deleted User)
Date: 22 Nov 2005 01:49 PM
Originally Posted: 22 Nov 2005 11:16 AM
Chris, Here is a sample .xslt file which gives you an idea of one way to create a fixed width file. I don't know if this bulleting board will mess up the formatting in the .xslt file. Just make sure that the line which defines $pad-string has lots of blanks, and the line which defines $new-line has a single new line character. Let us know if it helps, Clyde


Documentchris(1).xslt


Unknownchris.xml

Posttop
chris auSubject: how to navigate
Author: chris au
Date: 23 Nov 2005 02:45 AM
thanks it works....!!!

 
Topic Page 1 2 3 4 5 6 7 8 9 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.