BizTalk Utilities CV ,   Jobs ,   Code library
 
Home Page


Add/Edit your code items
Search the code library
Browse for the code library


XSLT
Preceding-subling XSL
Basic Shapes to Paths with TinyLine
XML to CSV using XSLT
Cross-Browser display of XML/XSL
Cross Reference Lookup in XSLT using XML file as Xref table
Recursion reminds me of Recursion (9 XSLT Recursion examples)
XSLT Sort - output entire xml file with new sort order
Variable Variables
Cross Reference Lookup in XSLT using embedded XML
XTrans 1.0
XML Explorer 2.5
Create an N-Column Table from XML node-set
XSLT Select Option Example
XSLT Date filtering, sorting, comparing, and evaluating
XSLT Template for HTML INPUT Tag
XSLT Template for HTML IMG Tag
XSLT Search and Replace Template
Word wrap and text replace templates for XSLT
nxslt 1.3
Visual XPath


 
 

<< XQuery.NET and XML >>


By John Workman
First Posted 04/19/2003
Times viewed 1169

Padding with XSLT


This post contains attachments
v20030419195352.zip 

Summary Template used to pad fields for fixed length flat file transforms. Also allows for truncation and left/right justification.

The following code demonstrates how to pad fields for fixed length file transforms. It will pad with zeros or spaces (or any other character), left or right justify, and will also truncate (if configured to do so) if the field is larger than the max size. If you set justification as right justified, and truncation to true, then the field will truncate to the left. Example: 'This is the name of the company', max=30, left justified, truncation = Y results: 'This is the name of the compan' 'This is the name of the company', max=30, right justified, truncation = Y results: 'his is the name of the company' You will often need to right justified, pad with zero, on numbers. My recommendation is to NOT truncate numbers. I prefer for the file to exceed the max length on the record than to truncate a number and have it import inaccurate information. Template used to pad fields for fixed length flat file transforms. Also allows for truncation and left and right justification. Updated on 9/23/2003 with fix to right justified, truncation issue.

Additional information

Further additional information


Rate this article on a scale of 1 to 10 (2 votes, average 2)

Your vote :  

<< XQuery.NET and XML >>





Leave a comment for this article
Your name
Your email (optional)
Your comment
Optional: Upload an attachment
Enter the code shown:

 
 

    Email TopXML