[Koha-devel] Random XSLT knowledge

Marcel de Rooy M.de.Rooy at rijksmuseum.nl
Fri Mar 8 08:13:12 CET 2024


Hi David,
Thanks for sharing.
Would you have an example of how you use register_function with Koha functions to share?

Marcel

________________________________
Van: Koha-devel <koha-devel-bounces at lists.koha-community.org> namens David Cook via Koha-devel <koha-devel at lists.koha-community.org>
Verzonden: vrijdag 8 maart 2024 03:02
Aan: 'Koha Devel' <koha-devel at lists.koha-community.org>
Onderwerp: [Koha-devel] Random XSLT knowledge


Hi all,



I’ve been working on performance issues, and in the process I got looking at XSLTs.



I just wanted to share that it’s possible to pass strings to the XSLT’s transform() method:



-    return $engine->transform($xmlrecord, $xslfilename ); #file or URL

+    return $engine->transform({

+        xml => $xmlrecord,

+        file => $xslfilename,

+        parameters => {

+            test => "'$test_str'",

+        },

+    }); #file or URL



It’s somewhat limited in that you can only pass strings and I think there’s a small limit on the number of parameters you can pass (not sure if it’s 32 or 255), but I thought it was interesting. It would allow you to pass some data that you have at hand on a per-XML record basis without having to mangle the XML record (like we do with items and system preferences).



In the end, I didn’t end up using it though. Instead, I use XML::LibXSLT->register_function() to provide access to Koha functions from the XSLT, and in this case that meets my needs.



Anyway, back to it..



David Cook

Senior Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia



Office: 02 9212 0899

Online: 02 8005 0595


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20240308/e60d82c6/attachment.htm>


More information about the Koha-devel mailing list