Subject: Re: [xsl] Str:tokenize modification to change the <token> tag From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Tue, 16 Apr 2002 14:34:52 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Str:tokenize modification, cutlass | Thread | Re: [xsl] Str:tokenize modification, Naresh Kumar Agarwal |
Re: [xsl] Str:tokenize modification, cutlass | Date | Re: [xsl] Str:tokenize modification, Ramesh B |
Month |