Page 1 of 1

Using EXSLT regexp (oXygen and EXSLT)

Posted: Sun May 24, 2009 9:05 pm
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.

Re: Using EXSLT regexp (oXygen and EXSLT)

Posted: Wed May 27, 2009 12:49 pm
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

Re: Using EXSLT regexp (oXygen and EXSLT)

Posted: Wed May 27, 2009 6:59 pm
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.

Re: Using EXSLT regexp (oXygen and EXSLT)

Posted: Thu May 28, 2009 9:55 am
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