xslt 1.0 - How padding char using xsl -


i want padding data space(any char) using xsl version 1.0.

name field max chars length 10 (length must dyanamic) chars.  need transfer data using xsl.  in xml: <emp> <name>test</name> </emp>  expected output :  <emp> <name>test******</name> </emp>  please let me know if have solution.  in advance.  

try:

substring(concat($yourstring, '**********'), 1, 10) 

example using input:

xslt 1.0

<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/> <xsl:strip-space elements="*"/>  <!-- identity transform --> <xsl:template match="@*|node()">     <xsl:copy>         <xsl:apply-templates select="@*|node()"/>     </xsl:copy> </xsl:template>  <xsl:template match="name">     <xsl:copy>         <xsl:value-of select="substring(concat(., '**********'), 1, 10)"/>     </xsl:copy> </xsl:template>  </xsl:stylesheet> 

result

<?xml version="1.0" encoding="utf-8"?> <emp>    <name>test******</name> </emp> 

alternatively, if processor supports it, use exslt str:align() function - possibly in conjunction str:padding() function create padding string dynamically.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -