Hi Nils,
 You can write a Java extension for using JDK's regex facility. I
tested successfully the following example with JDK 1.5.0_04 and
Xalan-J 2.7.0.

Java Class
----------------
import java.util.regex.Pattern;

public class RegExHelper {

 public static String matches(String regex, String input) {

   boolean b = Pattern.matches(regex, input);

   return Boolean.toString(b);

 }

}

Stylesheet
---------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                      version="1.0"
                      xmlns:java="http://xml.apache.org/xalan/java";
                      exclude-result-prefixes="java">

 <xsl:output method="text" />

 <xsl:template match="/">

    <xsl:variable name="booleanVal"
select='java:RegExHelper.matches("a*b", "aaaaab")' />

    <xsl:if test="$booleanVal = 'true'">
       Matches
    </xsl:if>

 </xsl:template>

</xsl:stylesheet>

Regards,
Mukul

On 5/8/06, Nils Kaiser <[EMAIL PROTECTED]> wrote:
Hello,

I am searching for an extension class to add regular expression support to
Xalan and XSLTC. Can anyone point me to such resource?

Of course best case would be to support the EXSLT syntax.

Thx,

Nils

Reply via email to