xsl-list
[Top] [All Lists]

RE: Another tokenize() question

2004-08-11 02:21:38
Interesting. My solution put everything into element structure and then used
for-each-group to add a level of hierarchy; David's solution put everything
into textual form and then used analyze-string to create the tree. Both seem
to work. What you can't do, it seems, is to handle the mix of textual
structure and element structure in one go.

Michael Kay 

-----Original Message-----
From: David Carlisle [mailto:davidc(_at_)nag(_dot_)co(_dot_)uk] 
Sent: 11 August 2004 10:01
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Another tokenize() question


analyze and regex
apart from my usual grotty level of typing, I have to cope with
American spelling as well...

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. 


some people want everything:-)

handling mixed content _across_ element boundaries is a bit more
complicated. Probably I'd do something like this
First have a mode a that does

<xsl:template mode="a" match="*">
<xsl:text>{</xsl:text>
<xsl:value-of select="name()"/><!-- perhaps atributes too if 
you need them-->
<xsl:text> </xsl:text>
<xsl:value-of select="."/>
<xsl:text>}</xsl:text>
</xsl:template>
 
Then run that inside a variable as a first pass so you get

 <l>Why ha{suppliedl}dest
 &thorn;u were agaynes me</l>

Then do your main ana-whatist-thingy, making sure anything inside
braces, ie "{[^{}]*}" is part of the "word" regexp


Then you would have

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

except that instead of using value-of in the matching-substring part
where you are adding <w> do another nested analyaze-strang 
and match on  
"{([a-z]*) ([^{}])*}
and put the <supplied> element back by using
<xsl:element name="{regex-group(1)}">
  <xsl:value-of select="regex-group(2)"/>
</xsl:element>


David


______________________________________________________________
__________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
______________________________________________________________
__________

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