Hi Andrei,

I'm the author of the saxon wrapper library at https://github.com/pjt/saxon.
User-defined XPath functions are indeed desirable but I haven't done
anything special in the library to help in implementing them.

What's available by default in Saxon is the ability to call Java
methods. For static methods, you associate a namespace in the XSLT
document with a class in Java, as in "nav" below:

  <xsl:stylesheet version="2.0"
xmlns:nav="java:net.sf.saxon.om.Navigator" xmlns:xsl="http://
www.w3.org/1999/XSL/Transform">

Then you can call static methods of that class as if it were an XPath
function, e.g.

  <xsl:value-of select="nav:getPath(.)">

Combine this with Clojure's class-generation facility (http://
clojure.org/compilation) & you can pretty easily see how to go about
writing Clojure extension functions. This isn't as convenient as one
could imagine, but it's a way to do it right now.

Best,
Perry


On Mar 1, 10:40 am, Trastabuga <lisper...@gmail.com> wrote:
> Hi
> I am eager to try out Clojure for my new web site. But for that I need
> XSLT support, like I used to have on Common Lisp (Xuriella XSLT) and
> also XPath support (like Plexippus XPath).
> I saw the saxon wrapper among the Clojure libraries but in its docs I
> couldn't find how they define user extensions. I wonder if Clojure has
> a library or some support for that now.
> To illustrate what I need is when you create your xsl page you should
> be able to define your extensions in lisp so that you can use it like
> this:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet version="1.0"
>                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>                 xmlns:func="http://www.yourwebsite.com/func";>
> ...................................
> <xsl:value-of select="func:my-lisp-function($some-parameter)"/>
> ..................................
> </xsl:stylesheet>
>
> Where my-lisp-function is the user defined extension in the 
> "http://www.yourwebsite.com/func"; namespace.
> Thank you,
> Andrei

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to