xsl-list
[Top] [All Lists]

Re: string manipulation

2002-10-26 16:04:35
You need to use recursion.  Something like the following might do it for
your attributes (warning: untested!):


<xsl:template match="/item">
  <xsl:call-template name="print-att">
    <xsl:with-param name="string" select="@key"/>
  </xsl:call-template>
</xsl:template>


<xsl:template name="print-att">
  <xsl:param name="string"/>
  <xsl:variable name="first" select="substring-before($string, ',')"/>
  <xsl:if test="$first">
    <xsl:value-of select="concat(' <-> ', $first"/>
    <xsl:call-template name="print-att">
      <xsl:with-param name="string" select="substring-after($string,
',')"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>



On Fri, 2002-10-25 at 10:52, john liao wrote:
Hi Listmembers,

I'm finding myself having to manipulate strings
because the tool that generates my xml can't generate
new elements that I need:

<item name="var1" description="subscribed
key=att1,att2 corc=att2,att3,att4,att21,att25"/>

I want to parse the description so I can print
key: att1
key: att2
a: att2
a: att3
a: att4
a: att21
a: att25

I can't figure it out using substring-before or
substring-after. Your help is very much appreciated.

J.L.

=====


__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.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



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