Using EXSLT regexp (oXygen and EXSLT)

Here should go questions about transforming XML with XSLT and FOP.
andrei
Posts: 3
Joined: Sun May 24, 2009 8:45 pm

Using EXSLT regexp (oXygen and EXSLT)

Post by andrei »

Hi,

I read Sorin's response on using EXSLT with oXygen, however it's still not clear on how exactly xsl needs to be adopted so that EXSLT regexp will work in transformation scenario with Xalan. For example below are xml and xsl containing regexp example from EXSLT web site. This example works just fine in Firefox (by opening xml file below)

XML:

Code: Select all

<?xml version="1.0" ?>
<?xml-stylesheet href="regexp_firefox_01.xsl" type="text/xsl"?>
<urls>
<url>http://www.bayes.co.uk:8080/xml/index.xml?/xml/utils/rechecker.xml</url>
</urls>
XSL (save it as regexp_firefox_01.xsl):

Code: Select all

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:regexp="http://exslt.org/regular-expressions"
extension-element-prefixes="regexp">
<xsl:output method="html" />
<xsl:template match="url">
<xsl:variable name="an_url" select="." />
<body>
<html>
<ul>
<li>string:</li>
<ul><li><xsl:value-of select="$an_url" /></li></ul>
<xsl:for-each select="regexp:match($an_url, '(\w+):\/\/([^/:]+):?(\d*)?([^# ]*)', 'i')">
<li>position <xsl:value-of select="position()" /></li>
<ul><li><xsl:value-of select="." /></li></ul>
</xsl:for-each>
</ul>
</html>
</body>
</xsl:template>
</xsl:stylesheet>
I added bsf.jar and js.jar as XSLT extensions to the oXygen transformation scenario. However it's not clear how exactly XSL above needs to be modified so it will work in Oxygen. Can someone post modified XSL example and detailed description of other steps required (e.g. adapted JavaScript code from the EXSLT stylesheets) so it will work?

Much appreciated.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Using EXSLT regexp (oXygen and EXSLT)

Post by sorin_ristache »

Hello,
andrei wrote:it's still not clear on how exactly xsl needs to be adopted so that EXSLT regexp will work in transformation scenario with Xalan
Xalan implements a subset of the EXSLT functions but this subset does not include the regexp functions. You have to import an XSLT stylesheet that implements the EXSLT regexp functions.


Regards,
Sorin
andrei
Posts: 3
Joined: Sun May 24, 2009 8:45 pm

Re: Using EXSLT regexp (oXygen and EXSLT)

Post by andrei »

Can you please give a working example for xslt that I posted above (I assume that stylesheet is part of ESLT downloads, not sure which one though)? I am using oXygen on Mac OS X. Much appreciated.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Using EXSLT regexp (oXygen and EXSLT)

Post by sorin_ristache »

You should just follow the example of using the regexp extensions. Just import the stylesheet from EXSLT and use the functions that you need.


Regards,
Sorin
Post Reply