This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: RegEx in XSLT?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]