[Koha-bugs] [Bug 11826] Improving code for XSLT handling

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Nov 17 03:03:27 CET 2014


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11826

--- Comment #29 from David Cook <dcook at prosentient.com.au> ---
(In reply to M. de Rooy from comment #27)
> (In reply to David Cook from comment #26)
> > I wonder if it would be useful to add a method for registering Perl
> > functions with the XML::LibXSLT object.
> > 
> > I suppose we wouldn't want staff clients users to inject Perl code, so it
> > would only be useful if we wanted to provide certain functions. I've used
> > this before in the XSLTs to encode URIs and stuff like that. 
> > 
> > I suppose if we need to register functions, we can just do it on a case by
> > case basis with whatever xslt handle is returned.
> 
> Interesting idea. I did not use these extensions functions, but I can
> imagine that some things are better done in Perl.
> Why not open a new report Register functions in XSLT_Handler? You can do it
> :)

After reading through the XML::LibXSLT documentation again (and some of the
libxslt documentation), I've realized that it isn't necessary to register
extension functions via the XML::LibXSLT object itself (and thus the
XSLT_Handler object).

"XML::LibXSLT->register_function($uri, $name, $subref)" registers extension
functions "globally", which can be done at the class level rather than the
object level. That is, after you load the XML::LibXSLT class module, you can
register functions regardless of the XSLTs that you need to parse or the
objects you use to do so. 

If I understand correctly, it's because the XML::LibXSLT is just an interface
to the libxslt C library. So you're not registering the extension function with
an object but rather the actual XSLT engine itself. 

It might be worth noting that the documentation says this might not be thread
or fork safe. I don't know what consequences that will have for folks running
with Plack. 

I am guessing that every extension function you register will stick around
until you restart Plack. I don't know if this will have any performance
consequences. Extension functions are pretty common (they get used all the time
in DSpace with the Xalan engine). So I don't know if there will be any negative
consequences, but perhaps something to keep in mind.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list