[xuriella-devel] Question concerning custom xpath functions returning node sets

R. Mattes rm at mh-freiburg.de
Tue May 8 19:42:21 UTC 2012


Dear list,

I'm trying to extend xuriella by writing some custom 
xpath functions (using plexippus' extension mechanism). 
This works fine for functions returning strings, booleans or
numbers, but I now need to write a function that returns a 
node set so that the following will work:

 <xsl:for-each select='my:fun("sample string", 3)'>
   <xsl:value-of select='pos()'/> <xsl:value-of select='.'/>
 </xsl:for-each>

My first (naive) implementation looked like this:

 (xpath-sys:define-xpath-function/eager 
    my fun (string &optional (count 1))
  (loop for i from 0 to count
        collect string into value-list
        finally (return (xpath-sys:make-node-set 
                         (xpath-sys:make-pipe (car value-list) (cdr
value-list))))))

Testing seem to work:

CL-USER> (xpath:with-namespaces (("my" "http://my.ns")) 
             (xpath:evaluate "my:myfun('blah')" nil))
#<XPATH:NODE-SET 3, ... {CB289B1}>
 
A nodeset, as expected.
But using this function in a stylesheet throw the following error:
CL-USER> (xuriella:apply-stylesheet #p"test.xsl" #p"test.xsl")


 There is no applicable method for the generic function
  #<STANDARD-GENERIC-FUNCTION
    XPATH-PROTOCOL:NODE-TEXT-USING-NAVIGATOR (7)>
 when called with arguments
  (:DEFAULT-NAVIGATOR "sample string").
   [Condition of type SIMPLE-ERROR]

What do I miss? (besides better documentation ;-)

TIA Ralf Mattes






More information about the xuriella-devel mailing list