[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Alice,
Are you using XSLT 1.0 or 2.0?
In 2.0, we have the function tokenize(), which makes this much easier. (It is also commonly available as a extension in 1.0: check your processor.)
In 1.0 you need to use a recursive template, not unlike what Mike just wrote about in the thread "[xsl] get value from link from last slash". You work through the string one item at a time by handling the first item and then calling the same template again with the remaining ones.
At 07:56 AM 11/14/2007, you wrote:
Re: [xsl] Split Strings with multiple spaces
Subject: Re: [xsl] Split Strings with multiple spaces From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Wed, 14 Nov 2007 11:51:13 -0500 |
Alice,
Are you using XSLT 1.0 or 2.0?
In 2.0, we have the function tokenize(), which makes this much easier. (It is also commonly available as a extension in 1.0: check your processor.)
In 1.0 you need to use a recursive template, not unlike what Mike just wrote about in the thread "[xsl] get value from link from last slash". You work through the string one item at a time by handling the first item and then calling the same template again with the remaining ones.
Cheers, Wendell
At 07:56 AM 11/14/2007, you wrote:
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
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Split Strings with multiple s, Alice Ju-Hsuan Wei | Thread | Re: [xsl] Split Strings with multip, Alice Ju-Hsuan Wei |
Re: [xsl] Spread a ul/li list in se, Steve | Date | Re: [xsl] Split Strings with multip, Alice Ju-Hsuan Wei |
Month |