[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] convert xml to fixed length format


Subject: [xsl] convert xml to fixed length format
From: a kusa <akusa8@xxxxxxxxx>
Date: Thu, 19 Sep 2013 10:14:22 -0500

Hello:

Is it possible to convert an xml file into a fixed length format?

For example, if I have an xml file as follows:
<products>
<product>
<id>12345</id>
<type>Toy</type>
<description> This is a soft toy</description>
</product>
<product>
<id>6789</id>
<type>Car</type>
<description> This is a car</description>
</product>
</products>

Now, I want to convert this into a fixed length format based on
specific string lengths. So if I defined id to be a fixed length of
10, type to be a fixed length of 25, and description to be a fixed
length of 50, I want a text file with these values, and the rest of
the spaces must be filled in such a way so as to meet the length
criteria. That means, if id was only 5 digits long, there should be
spaces for another 5 characters that total to 10, and the value for
type must start on the 11th digit.

Is this possible with XSLT?

Any help is appreciated.


Current Thread
Keywords
xml