[xsl] Split Strings with multiple spaces

Subject: [xsl] Split Strings with multiple spaces
From: Alice Ju-Hsuan Wei <ajwei@xxxxxxxxxxx>
Date: Wed, 14 Nov 2007 07:56:52 -0500
Hi,

I am really new to this, and I understand that in Tennison (2004) and Kay (2004), there is a function called substring-before and after to extract information before or after a certain element.

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">Brocololi, 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 reparse these elements in the XML recursively?

Thanks in advance.

Alice

Current Thread