[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] separating token problems
Subject: [xsl] separating token problems From: Sara Mitchell <samitchell6@xxxxxxxxx> Date: Wed, 14 Jun 2006 14:48:58 -0700 (PDT) |
I know there are existing tokenizing functions, however, I keep getting weird results with Xalan so to continue with the project, I wrote a template based on the EXSLT template to separate a string into separate tokens. This is somewhat simplified from the EXSLT version, because there is only 1 delimiter character. Seemed fairly simple, as Ive worked with recursive templates before. But, Ive stared at this for hours, tested the input at different rounds of recursion and am still getting weird results. Hopefully someone else can see the undoubtedly stupid mistake that Ive made. With an input string of input/xml/../ and a delimiter of / and this template: <xsl:template name="tokenize.path"> <xsl:param name="string" select="''"/> <xsl:param name="delimiter" select="' '"/> <xsl:variable name="normal.string" select="normalize-space($string)"/> <xsl:choose> <xsl:when test="contains($normal.string, $delimiter)"> <xsl:choose> <xsl:when test="starts-with($normal.string, $delimiter)"> <xsl:call-template name="tokenize.path"> <xsl:with-param name="string" select="substring($normal.string, 2)" /> <xsl:with-param name="delimiter" select="$delimiter" /> </xsl:call-template> </xsl:when> <xsl:when test="substring($normal.string,string-length($normal.string)) = $delimiter"> <xsl:call-template name="tokenize.path"> <xsl:with-param name="string" select="substring($normal.string,1,string-length($normal.string)-1)" /> <xsl:with-param name="delimiter" select="$delimiter" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <token><xsl:value-of select="substring-before($normal.string, $delimiter)"/></token> <xsl:call-template name="tokenize.path"> <xsl:with-param name="string" select="substring-after($normal.string, $delimiter)" /> <xsl:with-param name="delimiter" select="$delimiter" /> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="$string"> <token><xsl:value-of select="$normal.string"/></token> </xsl:when> </xsl:choose> </xsl:template> I get back: <token>input</token> <token>xml</token> <token>.. input/</token> Ive narrowed it down to the when test=$string clause but still cant figure out why the extra input/ is showing up. <head-bang/>. Any help would be appreciated. Sara Mitchell __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] $variable//childNode, David Carlisle | Thread | Re: [xsl] separating token problems, David Carlisle |
Re: [xsl] Floating point numbers in, Jagdishwar B | Date | Re: [xsl] $variable//childNode, David Carlisle |
Month |