[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: Regular expression functions (Was: Re: [xsl] comments on December F&O draft)
Subject: Re: Regular expression functions (Was: Re: [xsl] comments on December F&O draft) From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 8 Jan 2002 18:38:48 GMT |
> 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="([^
	
]*)([
	
])(.*)"> <xsl:value-of select="$1" /> <xsl:value-of select="if ($2 = '
') then '\n' else if ($2 = '	') then '\t' else if ($2 = '
') then '\r'" /> <xsl:apply-regexp-templates-to-string select="$3" /> </xsl:regexp-template> or just <xsl:regexp-template match="&#A;"> <xsl:text>\n</xsl:text> </xsl:regexp-template> <xsl:regexp-template match="&#D;"> <xsl:text>\r</xsl:text> </xsl:regexp-template> <xsl:regexp-template match="	"> <xsl:text>\t</xsl:text> </xsl:regexp-template> > 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')" /> </xsl:template> 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')" /> </xsl:template> once they decide what the constructor and/or casting function syntax is. But regexp matches are special in that they really do match into substrings. David _____________________________________________________________________ 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Regular expression functions (W, Jeni Tennison | Thread | Re: Regular expression functions (W, Jeni Tennison |
Re: Regular expression functions (W, Jeni Tennison | Date | RE: [xsl] XPath 2.0, Evan D. Lenz |
Month |