[Home] [By Thread] [By Date] [Recent Entries]
On 4/16/07, bryan rasmussen <rasmussen.bryan@xxxxxxxxx> wrote:
> > It would make far more sense for you to test your regular expressions by > some other means before putting them into your XSL. This is one way to way check if a pattern is valid: <xsl:stylesheet version="2.0" xmlns:regex="java.util.regex.Pattern" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://saxon.sf.net/"> <xsl:template match="/">
<xsl:value-of select="saxon:try(regex:compile(']['), 'false')"/>
</xsl:template></xsl:stylesheet> This attempts to compile the regex using Java, and catches the PatternSyntaxException using Saxon SA's saxon:try() function. In this case it returns "false" because "][" is invalid. If you don't have Saxon SA you could wrap the call in your own class to catch the exception and return a boolean. cheers andrew
|

Cart



