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

Re: RE: Regular expression functions (Was: Re: comment

Subject: Re: RE: Regular expression functions (Was: Re: comments on December F&O draft)
From: michael.h.kay@xxxxxxxxxxxx
Date: Mon, 14 Jan 2002 18:12:24 +0000
xsl template match regular expression
Well, it obviously can't work quite as you describe because your example is valid XSLT 1.0 syntax and doesn't involve a regexp at all!

But certainly, the way I'm leaning from this discussion is towards some kind of model where you submit a string to decomposition by means of a regexp and the decomposed pieces are then supplied to some kind of XSLT template, one at a time, for subsequent processing.

Mike Kay
> 
> From: "Chris Bayes" <chris@xxxxxxxxxxx>
> Date: Mon, 14 Jan 2002 04:13:12 -0000
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Subject: RE: Regular expression functions (Was: Re:  comments on December F&O draft)
> 
> Hi,
> I've been a bit tied up with one thing and another (and I think you
> might have discussed this before) but aren't regex matches just
> predicates on text nodes ala
> <xsl:template match="text()['\(.*\)']">
> 	<x><xsl:apply-templates select=".[1]" /></x>
> </xsl:template>
> Which applies templates to whatever is not matched (child texts) (but
> which matches the template). So that template on a text node
> "(a(b(c)d)e)" (assuming greedy)would produce
> <x>
>   a 
>   <x>
>     b
>     <x>
>      c
>     </x>
>     d
>   </x>
>   e
> </x>
> Of course you could always stick it in a variable
> 
> <xsl:variable name="match-tree">
> 	<xsl:apply-templates select="'(a(b(c)d)e)'" />
> </xsl:variable>
> 
> Ok I'm thinking too tree like. What if "2002-01-01"
> 
> <xsl:template match="text()['(.*?)-(.*?)-(.*?)']">
> 	<year><xsl:apply-templates select=".[1]" /></year>
> 	<month><xsl:apply-templates select=".[2]" /></month>
> 	<day><xsl:apply-templates select=".[3]" /></day>
> </xsl:template>
> 
> Or "2002-01-Wednesday 2nd"
> 
> <xsl:template match="text()['(.*?)-(.*?)-(.*?)']">
> 	<year><xsl:apply-templates select=".[1]" /></year>
> 	<month><xsl:apply-templates select=".[2]" /></month>
> 	<xsl:apply-templates select=".[3]" />
> </xsl:template>
> <xsl:template match="text()['(.*?) (.*?)']">
> 	<day><xsl:apply-templates select=".[1]" /></day>
> 	<date><xsl:apply-templates select=".[2]" /></date>
> </xsl:template>
> 
> Or "2002-01-Wednesday 2nd"
> 
> <xsl:template match="text()['(.*?)-(.*?)-(.*?)']">
> 	<year><xsl:apply-templates select=".[1]" /></year>
> 	<month><xsl:apply-templates select=".[2]" /></month>
> 	<xsl:apply-templates select="concat('doh!', .[3])" />
> </xsl:template>
> <xsl:template match="text()['doh!(.*?) (.*?)']">
> 	<day><xsl:apply-templates select=".[1]" /></day>
> 	<date><xsl:apply-templates select=".[2]" /></date>
> </xsl:template>
> 
> Maybe it's rubbish but it doesn't look too alien to me. What other
> useful predicates can you put on a text node? Surely it isn't going to
> clash with anything. There are nearly 1000 pages of wd's to look at here
> so looking at it another way is there anything that says that . can't be
> a sequence and that I can't index into it with .[x]?
> 
> Ciao Chris
> 
> XML/XSL Portal
> http://www.bayes.co.uk/xml
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.