Subject: Re: [xsl] Str:tokenize modification to change the <token> tag From: Ramesh B <ramesh_bhanu@xxxxxxxxx> Date: Tue, 16 Apr 2002 06:48:05 -0700 (PDT) |
Hi, See whether you can use the following Template i had used to split a string <xsl:template name="SplitString"> <xsl:param name="prm" select="'nothing'"/> <xsl:choose> <xsl:when test="contains($prm,',')"> <token><xsl:value-of select="substring-before($prm,',')"/></token> <xsl:call-template name="SplitString"> <xsl:with-param name="prm" select="substring-after($prm,',')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <token><xsl:value-of select="$prm"/></token> </xsl:otherwise> </xsl:choose> </xsl:template> Regards, Ramesh --- Naresh Kumar Agarwal <nagarwal@xxxxxxxxxxxxx> wrote: > Hi, > > I'm new to XSL and need to use XSLT to tokenize, > like in Java. > > I used str:tokenize and it worked > (http://www.exslt.org/str/functions/tokenize/) > > I need to split > > <description> I am doing good<description> > > to > > <desc>I<desc> > <desc>am<desc> > <desc>doing<desc> > <desc>good<desc> > > Later on, I need to split, > > <function>a,b,c,d,e<function> > > to > > <func>a<func> > <func>b<func> > <func>c<func> > <func>d<func> > <func>e<func> > > Using str:tokenize, I'm getting the result as > > <token>I<token> > <token>am<token> > <token>doing<token> > <token>good<token> > > 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. > > How can I modify this <token> tag and pass it as a > parameter (like the string > and delimiter)? > > Any help would be greatly appreciated. I need it > urgently. > > Thanks so much, > Naresh. > > <xsl:template name="_tokenize-delimiters"> > <xsl:param name="string" /> > <xsl:param name="delimiters" /> > > <!---Begin: my modification--> > <xsl:param name="tokentag" select="token" /> > <xsl:variable name="start_tag" select="concat('<', > $tokentag,'>')" /) > <xsl:variable name="end_tag" > select="concat('</',$tokentag,'>')" /) > <!--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:value-of select="$start_tag" > /><xsl:value-of select="$string" > /><xsl:value-of select="$end_tag" /> > > </xsl:when> > <xsl:when test="contains($string, $delimiter)"> > <xsl:if test="not(starts-with($string, > $delimiter))"> > <xsl:call-template > name="_tokenize-delimiters"> > <xsl:with-param name="string" > select="substring-before($string, > $delimiter)" /> > > > XSL-List info and archive: > http://www.mulberrytech.com/xsl/xsl-list > __________________________________________________ Do You Yahoo!? Yahoo! Tax Center - online filing with TurboTax http://taxes.yahoo.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Str:tokenize modification, Naresh Kumar Agarwal | Thread | Re: [xsl] Str:tokenize modification, Vasu Chakkera |
Re: [xsl] Str:tokenize modification, Jeni Tennison | Date | Re: [xsl] Performance Issue using c, Johannes Döbler |
Month |