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

Re: Regular expression functions (Was: Re: comments on

Subject: Re: Regular expression functions (Was: Re: comments on December F&O draft)
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 8 Jan 2002 18:38:48 GMT
xsl regex
> Presumably the match patterns would match the entire string? 

you think I have any idea how it's supposed to work?

Actually no i think not see in my example first the \gamma template
fired then the \sqrt one even though they're in the same string.

<xsl:regexp-template match="([^&#xA;&#x9;&#xD;]*)([&#xA;&#x9;&#xD;])(.*)">
  <xsl:value-of select="$1" />
  <xsl:value-of select="if ($2 = '&#xA;') then '\n'
                        else if ($2 = '&#x9;') then '\t'
                        else if ($2 = '&#xD;') then '\r'" />
  <xsl:apply-regexp-templates-to-string select="$3" />

or just

<xsl:regexp-template match="&#A;">
<xsl:regexp-template match="&#D;">
<xsl:regexp-template match="&#9;">

> The big weakness if this was the *only* method of doing matches is
> that you can't use it with dynamic regular expressions - for example
> match strings that contain the keyword $keyword as a word. Any ideas
> around that one?

Currently template matches don't allow global variables in a (failed)
attempt to prevent circularity, if template matches could have global
variables references then these regexp ones could too. then of course
you'd have to decide if the regexp string attribute was an xpath
expression and so make up the regexp using concat() or whether it is a
string but allow expath expressions such as variable references using
avt {}.

>  occurred to me that this could be useful if, for example, you
> wanted all your numbers to be formatted in the same way throughout the
> document - you could have:

  <xsl:template match="value of type xs:decimal">
    <xsl:value-of select="format-number(., '#,##0.00')" />

but if an element node is schema typed you can presumably go

<xsl:template match="text()[. = cast-to-decimal(.)]">
  <xsl:value-of select="format-number(., '#,##0.00')" />

once they decide what the constructor and/or casting function syntax is.
But regexp matches are special in that they really do match into


This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

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

Current Thread


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.
First Name
Last Name
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.