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

Re: Another tokenize() question

Subject: Re: Another tokenize() question
From: James Cummings <James.Cummings@xxxxxxxxxxxxxx>
Date: Tue, 10 Aug 2004 18:07:26 +0100 (BST)
string tokenize
On Tue, 10 Aug 2004, David Carlisle wrote:
> <xsl:template match="l">
>  <l>
>   <xsl:apply-templates/>
>  </l>
> </xsl:template>
> 
> <xsl:template match="l/text()"> <!-- or l//text() according to taste-->
>  <xsl:analyse-string regexp="\w+" select=".">
>    <xsl:matching-substring><w><xsl:value-of select="."/></w></xsl:matching-substring>
>    <xsl:non-matching-substring><xsl:value-of select="."/></xsl:non-matching-substring>
>  </xsl:analyse-string>
> </xsl:template>
> 
> Now if you do it this way you don'tjust get a list of w elements one for
> each word you get them in situ, and around them you get your non-word
> characters and anything that came from the apply-templates in the
> template for l.


Always first to respond and teach me something new.  I didn't know 
about xsl:analyze-string.  (And of course you've left some typoes in 
to make sure I'm awake, analyze and regex I'm assuming.)

Ok.  This *basically* works, but with a line like:

<l>Why ha<supplied>l</supplied>dest &thorn;u were agaynes me</l>

it turns it into:

<l><w>Why</w> <w>ha</w><supplied>l</supplied><w>dest</w> <w>&thorn;u</w>
<w>were</w> <w>agaynes</w> <w>me</w></l>

or if I change it to l//text()

<l><w>Why</w> <w>ha</w><supplied><w>l</w></supplied><w>dest</w>
<w>&thorn;u</w> <w>were</w> <w>agaynes</w> <w>me</w></l>

When really:

<l><w>Why</w> <w>ha<supplied>l</supplied>dest</w> <w>&thorn;u</w>
<w>were</w> <w>agaynes</w> <w>me</w></l>

is what is wanted.  (The supplied letter being part of the word in this
case rather than a separate word.)
---
Dr James Cummings, Oxford Text Archive, University of Oxford
James dot Cummings at oucs dot ox dot ac dot uk 
CALL FOR PAPERS: Digital Medievalism (Kalamazoo) and 
Early Drama (Leeds) see http://users.ox.ac.uk/~jamesc/cfp.html

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.