Ram
Ram

Reputation: 1

How to add or suffix spaces in xslt 1.0

looking for syntax how to add or suffix extra spaces in xslt 1.0.

i am working on ISO2022cgi payment template. i have customized the template as bank requirement. we have to send data with 35 characters length so bank can consider 36th character as new line. so bank expecting extra spaces to suffix.

eg: 'data '
when i tried to include spaces the xml output provide single space. tired non breaking values like   and   this is providing required spaces but , bank not accepting hex values.

need a help here how to pad or suffix spaces in xslt. thanks Ram

Upvotes: 0

Views: 185

Answers (1)

John Ernst
John Ernst

Reputation: 1235

This is for XSLT 1.0:

<xsl:variable name="spaces35" select="'                                   '"/>

<xsl:variable name="test" select="'Pad this'"/>

<!-- Do this is the you want to padr and the max number of spaces you want is 35.  -->  
<xsl:variable name="padr35" select="substring(concat($test, $spaces35), 1, 35)"/>

<!-- This is padding right 35 but the final string length can be more than 35, if the input string is longer than 35.  -->
<xsl:variable name="PaddingR35" select="concat($test, substring($spaces35, 1, 35 - string-length($test)))"/>

Upvotes: 1

Related Questions