xsl-list
[Top] [All Lists]

Re: Strings Position

2003-11-25 15:14:00
Bruno LLopes wrote:
I have a string for exemple '00643cam 022002291 04500'
and I need look at every position of the string a see if each element
has the correct value...
How can  I shift the string position by position?

I'm not quite sure what your question is. If you want to split
your string at certain positions, use substring(), for example
 <xsl:variable name="part1" select="substring($str,1,8)"/>
If you want to split the string at certain characters, use
substring-before() and substring-after(), like in
 <xsl:variable name="part1" select="substring-before($str,' ')"/>

If the string contains multiple parts, you can program unrolled code,
like
 <xsl:variable name="part1" select="substring-before($str,' ')"/>
 <xsl:variable name="tail1" select="substring-after($str,' ')"/>
 <xsl:variable name="part2" select="substring-before($tail1,' ')"/>
 <xsl:variable name="tail2" select="substring-after($tail1,' ')"/>
or use a recursive template as described in the XSL FAQ:
 http://www.dpawson.co.uk/xsl/sect2/N7240.html#d8065e280

J.Pietschmann


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>