[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: New to XSL

Subject: RE: New to XSL
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 21 Dec 2005 10:37:40 -0000
xsl datum
Try to choose a subject line that relates to your problem: at least half the
questions on this list are from people new to XSL.

Yes, it is possible. Like many things, it is much easier in XSLT 2.0 than in
XSLT 1.0. 

(I'm not sure what part the sep attribute plays in your problem, so I'm
ignoring it)

In 2.0, you can do

<xsl:for-each select="tokenize(textarea, '\s+')">
  <datum>
    <xsl:value-of select="."/>
  </datum>
</xsl:for-each>

(If the whitespace in your example output is significant, you'll need to add
it.)

In 1.0 you need to write a recursive named template. This reads and
processes the first item in the list using substring-before($input, ' '); it
then calls itself to process the remaining items in the list, identified
using substring-after($input, ' '). This takes a little bit of getting used
to at first if you don't have a background in functional programming. The
easiest way to get started might be to download the str:tokenize template
from www.exslt.org (which simply does what I described above) and integrate
it into your code.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Richard Zhang [mailto:richard_zhang@xxxxxxxxxx] 
> Sent: 20 December 2005 16:21
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  New to XSL
> 
> Hi,
> 
> I am new to XSLT and want to do the following but do not know 
> if it is 
> possible or not. Any help or references to sources would be greatly 
> appreciated.
> 
> I have an XML file with the following element:
> 
> <textarea sep=" &#x000A; &#x000D:"
>   10 20 30 40 50
> </textarea>
> 
> And I would like to be able to transform it into:
> 
> <datum>
>   10
> </datum>
> <datum>
>   20
> </datum>
> <datum>
>   30
> </datum>
> <datum>
>   40
> </datum>
> <datum>
>   50
> </datum>
> 
> Is this possible with XSLT?
> 
> Thank you in advance for any help.
> 
> Richard.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.