![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: string to char conversion [Thread Next] Re: string to char conversionTo: NULL Date: 3/16/2006 12:46:00 AM Thanks alot Anthony,
I found a solution myself (based on yours):
I needed some time to find out that the first character of a string
doen`s have the index '0' ( compared to common programming languages)
but has the index '1'.
This is the reason I pass '1' in next_char_index as initial parameter
for the
string _to_char template.
The "calling template":
<xsl:template ... >
.....
<xsl:call-template name="string_to_char">
<xsl:with-param name="next_char_index" select="'1'"/>
</xsl:call-template>
.....
</xsl:template ... >
<xsl:template name="string_to_char">
<xsl:param name="next_char_index" />
<xsl:variable name="string_length" select="string-length(@value)"/>
<xsl:variable name="string" select="@value"/>
<xsl:if test="$string_length >= $next_char_index">
<xsl:element name="char">
<xsl:attribute name="value">
<xsl:value-of
select="substring($string,$next_char_index,1)"/>
</xsl:attribute>
</xsl:element>
<xsl:call-template name="string_to_char">
<xsl:with-param name="next_char_index"
select="$next_char_index+1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
cheers,
Boris
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
