This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: RegEx in XSLT?
- From: "Mario Michlits" <mario dot michlits at hico dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 28 Mar 2002 18:23:29 +0100
- Subject: RE: [xsl] RegEx in XSLT?
- Reply-to: xsl-list at lists dot mulberrytech dot com
Regexp-matching is not actually powerful with XSLT alone.
But there are a lot of possibilities concerning extension functions. The way of integrating them depends on the processor you are using.
Saxon for example can integrate java-functions somehow like this, by defining a namespace to a java class:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:RegexpClass="http://www.jclark.com/xt/java/com.hico.onlaw.convert.RegexpClass">
Then in the stylesheet in which you use the functions you can define variables like:
<xsl:variable name="RegexpFunction" select="RegexpClass:new()"/>
For example, one application of regexp-functions in my stylesheet looks like this:
<xsl:variable name="doknr">
<xsl:if test="Regexp:matchRegex($RegexpFunction, ris.c/ris.c.doknr, '&ris.c.doknr;')">
<r1>
<v1>
<xsl:value-of select="Regexp:getMatchRes($RegexpFunction, 1)"/>
</v1>
<v2>
<xsl:value-of select="Regexp:getMatchRes($RegexpFunction, 2)"/>
</v2>
<v3>
<xsl:value-of select="Regexp:getMatchRes($RegexpFunction, 3)"/>
</v3>
</r1>
</xsl:if>
</xsl:variable>
Hope this was helpful input
regards
Mario
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list