# EXSLT func:function not registered for XSLT filter module

**URL:** <https://www.ruby-forum.com/t/exslt-func-function-not-registered-for-xslt-filter-module/235760>\
**Category:** NGINX\
**Created:** [July 13, 2013, 12:20pm UTC](https://www.ruby-forum.com/t/exslt-func-function-not-registered-for-xslt-filter-module/235760 "2013-07-13T12:20:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [July 13, 2013, 12:20pm UTC](https://www.ruby-forum.com/t/exslt-func-function-not-registered-for-xslt-filter-module/235760/1 "2013-07-13T12:20:30Z")

</div>

Hi,

I’m trying to use EXSLT’s func:function with nginx’s xslt filter  
module. The effect I think I’m seeing is that my functions are  
seemingly ignored.

I made a test XSLT stylesheet:

```
iona% cat xsl/fish.xsl
<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:x="http://xml.elide.org/fish"
     xmlns:func="http://exslt.org/functions"

    extension-element-prefixes="func">

    <func:function name="x:fish">
        <func:result select="123"/>
    </func:function>

    <xsl:output method="text" encoding="utf-8"
        media-type="plain/text"/>

    <xsl:template match="/">
        <xsl:value-of select="x:fish()"/>
        <xsl:text>&#10;</xsl:text>
    </xsl:template>

</xsl:stylesheet>

iona% xsltproc xsl/fish.xsl vhost/blog.libfsm.org/index.xhtml5
123
iona%

```

I would expect my \<xsl:value-of select=“x:fish()”/\> there to give the  
same result as under xsltproc. But running the same under nginx gives:

```
xmlXPathCompOpEval: function fish not found
XPath error : Unregistered function
xmlXPathCompiledEval: evaluation failed
runtime error: file /home/kate/svn/www/xsl/fish.xsl line 19 element 

```

value-of  
XPath evaluation returned no result.

Looking at ngx\_http\_xslt\_filter\_module.c I see exsltRegisterAll() is  
called, which is what should register libexslt’s handler for  
func:function and friends:

```
#if (NGX_HAVE_EXSLT)
    exsltRegisterAll();
#endif

```

I know NGX\_HAVE\_EXSLT is defined because other EXSLT functions (such  
as things in the date: and str: namespaces) work fine.

I’m using nginx 1.4.1, which is linked to the same libexslt as my  
xsltproc.

Any suggestions, please?

–  
Kate

---

<div class="post-metadata">

**Author:** ![Kate\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b5a626/32.png) [@Kate\_F](https://www.ruby-forum.com/u/Kate_F)\
**Post date:** [July 15, 2013, 7:32pm UTC](https://www.ruby-forum.com/t/exslt-func-function-not-registered-for-xslt-filter-module/235760/2 "2013-07-15T19:32:42Z")

</div>

Hello!

On Sat, Jul 13, 2013 at 12:19:51PM +0200, Kate F wrote:

> Hi,
> 
> I’m trying to use EXSLT’s func:function with nginx’s xslt filter  
> module. The effect I think I’m seeing is that my functions are  
> seemingly ignored.

[…]

> Looking at ngx\_http\_xslt\_filter\_module.c I see exsltRegisterAll() is  
> called, which is what should register libexslt’s handler for  
> func:function and friends:
> 
> ```
> #if (NGX_HAVE_EXSLT)
> exsltRegisterAll();
> #endif
> 
> ```
> 
> I know NGX\_HAVE\_EXSLT is defined because other EXSLT functions (such  
> as things in the date: and str: namespaces) work fine.

It looks like exsltRegisterAll() is called too late for EXSLT  
Functions extension.

Please try the following patch:

# HG changeset patch

# User Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

# Date 1373909466 -14400

# Node ID bc1cf51a5b0a5e8512a8170dc7991f9e966c5533

# Parent 8e7db77e5d88b20d113e77b574e676737d67bf0e

Xslt: exsltRegisterAll() moved to preconfiguration.

The exsltRegisterAll() needs to be called before XSLT stylesheets  
are compiled, else stylesheet compilation hooks will not work. This  
change fixes EXSLT Functions extension.

diff --git a/src/http/modules/ngx\_http\_xslt\_filter\_module.c  
b/src/http/modules/ngx\_http\_xslt\_filter\_module.c  
— a/src/http/modules/ngx\_http\_xslt\_filter\_module.c  
+++ b/src/http/modules/ngx\_http\_xslt\_filter\_module.c  
@@ -104,6 +104,7 @@ static void \*ngx\_http\_xslt\_filter\_create  
static void \*ngx\_http\_xslt\_filter\_create\_conf(ngx\_conf\_t \*cf);  
static char \*ngx\_http\_xslt\_filter\_merge\_conf(ngx\_conf\_t \*cf, void  
\*parent,  
void \*child);  
+static ngx\_int\_t ngx\_http\_xslt\_filter\_preconfiguration(ngx\_conf\_t \*cf);  
static ngx\_int\_t ngx\_http\_xslt\_filter\_init(ngx\_conf\_t \*cf);  
static void ngx\_http\_xslt\_filter\_exit(ngx\_cycle\_t \*cycle);

@@ -163,7 +164,7 @@ static ngx\_command\_t

static ngx\_http\_module\_t ngx\_http\_xslt\_filter\_module\_ctx = {

- NULL, /\* preconfiguration \*/

- ngx\_http\_xslt\_filter\_preconfiguration, /\* preconfiguration _/  
ngx\_http\_xslt\_filter\_init, /_ postconfiguration \*/

static ngx\_int\_t  
-ngx\_http\_xslt\_filter\_init(ngx\_conf\_t \*cf)  
+ngx\_http\_xslt\_filter\_preconfiguration(ngx\_conf\_t \*cf)  
{  
xmlInitParser();

@@ -1119,6 +1120,13 @@ ngx\_http\_xslt\_filter\_init(ngx\_conf\_t  
exsltRegisterAll();  
#endif

- return NGX\_OK;  
+}
- 
- 

+static ngx\_int\_t  
+ngx\_http\_xslt\_filter\_init(ngx\_conf\_t \*cf)  
+{  
ngx\_http\_next\_header\_filter = ngx\_http\_top\_header\_filter;  
ngx\_http\_top\_header\_filter = ngx\_http\_xslt\_header\_filter;

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**

---

<div class="post-metadata">

**Author:** ![Kate\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b5a626/32.png) [@Kate\_F](https://www.ruby-forum.com/u/Kate_F)\
**Post date:** [July 17, 2013, 6:18pm UTC](https://www.ruby-forum.com/t/exslt-func-function-not-registered-for-xslt-filter-module/235760/3 "2013-07-17T18:18:41Z")

</div>

On 15 July 2013 19:32, Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> […]
> 
> > as things in the date: and str: namespaces) work fine.
> 
> # Parent 8e7db77e5d88b20d113e77b574e676737d67bf0e
> 
> Xslt: exsltRegisterAll() moved to preconfiguration.
> 
> The exsltRegisterAll() needs to be called before XSLT stylesheets  
> are compiled, else stylesheet compilation hooks will not work. This  
> change fixes EXSLT Functions extension.

Awesome! Good catch.

Thanks for that. Your patch works fine.

–  
Kate

---

<div class="post-metadata">

**Author:** ![Kate\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b5a626/32.png) [@Kate\_F](https://www.ruby-forum.com/u/Kate_F)\
**Post date:** [July 19, 2013, 2:04pm UTC](https://www.ruby-forum.com/t/exslt-func-function-not-registered-for-xslt-filter-module/235760/4 "2013-07-19T14:04:00Z")

</div>

Hello!

On Wed, Jul 17, 2013 at 06:18:03PM +0200, Kate F wrote:

> > > I know NGX\_HAVE\_EXSLT is defined because other EXSLT functions (such
> > 
> > # Node ID bc1cf51a5b0a5e8512a8170dc7991f9e966c5533
> > 
> > # Parent 8e7db77e5d88b20d113e77b574e676737d67bf0e
> > 
> > Xslt: exsltRegisterAll() moved to preconfiguration.
> > 
> > The exsltRegisterAll() needs to be called before XSLT stylesheets  
> > are compiled, else stylesheet compilation hooks will not work. This  
> > change fixes EXSLT Functions extension.
> 
> Awesome! Good catch.
> 
> Thanks for that. Your patch works fine.

Committed, thanks for testing.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**
