Re: [xsl] Str:tokenize modification to change the <token> tag

Subject: Re: [xsl] Str:tokenize modification to change the <token> tag
From: Naresh Kumar Agarwal <nagarwal@xxxxxxxxxxxxx>
Date: Wed, 17 Apr 2002 16:54:20 +0800
Thanks so much Cutlass, Jeni and Ramesh.

Its working now.

Cheers,
Naresh.

On Tuesday 16 April 2002 09:34 pm, Jeni Tennison wrote:
> Hi Naresh,
>
> > I want to make this "<token>" tag configurable, so that str:tokenize
> > can take it as a parameter.
> >
> > But whenever I try to modify the code (see changes made below) of
> > str:tokenize, I get an illegal character error.
>
> That's because you're trying to write the result of the template as if
> you were constructing a string, whereas what you should be doing (what
> XSLT does) is create a *tree*. You should try to stop thinking in
> terms of start tags and end tags, and instead think in terms of
> elements.
>
> So you should think of it in terms of "I want to make it create an
> element with a different name." You can create an element with a
> given name using the xsl:element instruction with an attribute value
> template in its name attribute. For example:
>
>   <xsl:element name="{$token}">
>     ...
>   </xsl:element>
>
> creates an element whose name is the string value of the $token
> variable.
>
> Adding this to the modified template, you get:
>
> <xsl:template name="_tokenize-delimiters">
>   <xsl:param name="string" />
>   <xsl:param name="delimiters" />
>
>   <!---Begin: my modification-->
>   <xsl:param name="tokentag" select="'token'" />
>   <!--End: my modification-->
>
>   <xsl:variable name="delimiter" select="substring($delimiters, 1, 1)" />
>   <xsl:choose>
>     <xsl:when test="not($delimiter)">
>
>       <!-- commented by me -->
>       <!--<token><xsl:value-of select="$string" /></token>-->
>
>       <!-- added by me -->
>       <xsl:element name="$tokentag">
>         <xsl:value-of select="$string" />
>       </xsl:element>
>     </xsl:when>
>     ...
>   </xsl:choose>
>   ...
> </xsl:template>
>
> Cheers,
>
> Jeni
>
> ---
> Jeni Tennison
> http://www.jenitennison.com/
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

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


Current Thread