[xsl] Recursive Split

Subject: [xsl] Recursive Split
From: Alice Ju-Hsuan Wei <ajwei@xxxxxxxxxxx>
Date: Wed, 14 Nov 2007 09:59:35 -0500

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:

                  <to_do xml:id="cheese">Cheddar Cheese</to_do>
                  <to_do xml:id="beef">Chuck Steak</to_do>
                  <to_do xml:id="vegetables">Brocololi, Beans,
                  <to_do xml:id="milk">Dean's Low Fat Milk 2%</to_do>

 <list>milk cheese vegetables beef</list>

Current XSL:

<xsl:template name="do_list">
    <xsl:variable name="item" select="list"/>
    <xsl:variable name="tasks" select="substring-after($item, ' ')"/>
          <xsl:when test="contains($item,' '
                 <xsl:value-of select="id($item)"/>
              <xsl:apply-templates select="$item"/>

Intended Output in HTML:

                  <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.


Current Thread