Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: XSLT function for padding value with characters >Thread Next - Re: XSLT function for padding value with characters Re: XSLT function for padding value with charactersTo: NULL Date: 5/5/2007 8:00:00 PM Martin, Thank you for the reply. I finally got it to work once I figured out that the spaces in the select must be enclosed in single-quote (apostrophe) characters. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting LLC www.cpearson.com (email on the web site) "Martin Honnen" <mahotrash@y...> wrote in message news:eG7XImYjHHA.4032@T...... > Chip Pearson wrote: >> I am considering using XSLT to take existing XML data files and creating >> text files that will be imported to other programs. These import files >> must be formatted text not XML. For example, vendor numbers must be 12 >> digits padded on the left with 0's and product names must be 30 >> characters padded on the right with spaces. Is there a way using XSLT to >> pad out a value to a specified length using a specified padding >> character? I can't have the formatted values in the XML data itself >> because one XML node value will be going to multiple output text files >> each with its own formatting requirements. > > <xsl:param name="spaces" > select=" "/> > <!-- 30 space characters --> > > Now if you have an element ProductName you can do e.g. > > <xsl:value-of select="concat(ProductName, substring($spaces, 1, 30 - > string-length(ProductName)))"/> > > You could put that stuff in a template and call it as needed. > > > -- > > Martin Honnen --- MVP XML > http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
