| 
 
Subject: RE: [xsl] Recursive Split From: "Angela Williams" <Angela.Williams@xxxxxxxxxxxxxxxxxx> Date: Wed, 14 Nov 2007 10:12:17 -0600  | 
Instead of substring-after, try tokenize() to split the string in list
on the space into a sequence of strings.
<xsl:variable name="list-items" select="tokenize($item , '\s+' )"/>
Then you can iterate through list-items to do what you need:
<xsl:for-each select="$list-items">
  item is: [<xsl:value-of select="."/>]
</xsl:for-each>
Gives you:
        item is: [milk]
        item is: [cheese]
        item is: [vegetables]
        item is: [beef]
Thanks!
Angela
-----Original Message-----
From: Alice Ju-Hsuan Wei [mailto:ajwei@xxxxxxxxxxx]
Sent: Wednesday, November 14, 2007 9:00 AM
To: xsl-list
Subject: [xsl] Recursive Split
Hi,
  Does anyone know if it is possible to do recursive splitting of
strings and output them with appropriate ids? I tried using
substring-before and substring-after, but I can only be applied once, so
when I have multiple elements I wanted to split, it does not provide the
accurate output.
Here is my XML:
              <listItem>
                   <to_do xml:id="cheese">Cheddar Cheese</to_do>
               </listItem>
                <listItem>
                   <to_do xml:id="beef">Chuck Steak</to_do>
               </listItem>
                <listItem>
                   <to_do xml:id="vegetables">Brocoli, Beans,
Carrots</to_do>
               </listItem>
               <listItem>
                   <to_do xml:id="milk">Dean's Low Fat Milk 2%</to_do>
               </listItem>
  <do>
  <date>2007-11-14</date>
  <list>milk cheese vegetables beef</list>
  <limit_price>20</limit_price>
  <do>
  Current XSL:
<xsl:template name="do_list">
     <xsl:variable name="item" select="list"/>
     <xsl:variable name="tasks" select="substring-after($item, ' ')"/>
       <xsl:choose>
           <xsl:when test="contains($item,' '
                  <xsl:value-of select="id($item)"/>
                   </xsl:when>
           <xsl:otherwise>
               <xsl:apply-templates select="$item"/>
           </xsl:otherwise>
       </xsl:choose>
   </xsl:template>
  Intended Output in HTML:
     <ul>
                   <li>Cheddar Cheese</li>
                  <li>Chuck Steak</li>
                  <li>Brocololi, Beans, Carrots</li>
                  <li>Dean's Low Fat Milk 2%</li></ul>
   Is it possible to parse these elements in the XML recursively?
Thanks in advance.
Alice
| Current Thread | 
|---|
  | 
| <- Previous | Index | Next -> | 
|---|---|---|
| [xsl] Recursive Split, Alice Ju-Hsuan Wei | Thread | RE: [xsl] Recursive Split, Alice Ju-Hsuan Wei | 
| Re: [xsl] RE: How to pass VBScript , Steve | Date | Re: [xsl] Template matching precedi, Wendell Piez | 
| Month |