xsl-list
[Top] [All Lists]

[xsl] Split Strings with multiple spaces

2007-11-14 05:57:21
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





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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