Almost by accident, I stumbled on a hint that xsltproc has some crypto
functions available as "extension functions". And they are part of the EXSLT
library we rely on heavily already. Plus, I have a need for them now (short
unique filenames for some knowl content).
1. In an XSLT stylesheet add the following to the "xsl:stylesheet" where
similar declarations are made.
xmlns:crypt="
http://exslt.org/crypto"
2. In some template that is sure to be called a lot insert
<xsl:message>
<xsl:value-of select="crypt:sha1('foobar')"/>
</xsl:message>
3. Now process some document with xsltproc and you'll see lots of
8843d7f92416211de9ebb963ff4ce28125932878
in the console. (Which matches what I get at
http://www.sha1-online.com/ !)
Now, use the pretext/pretext script, which will use the Python lxml module
which has always been seemingly 100% compatible with xsltproc since they are
built on the same libraries.
This will produce messages:
xmlXPathCompOpEval: function sha1 not found
Unregistered function
which is odd, since "xsltproc -dumpextensions" says *it is* registered.
A. The lxml "XSLT" object has an "extensions" keyword. We've not needed it for
other EXSLT functions. I was able to get the syntax right, but what I tried was
not effective. I wonder if a Pythonista could do better?
https://lxml.de/api/lxml.etree.XSLT-class.html
B. I'm guessing this is code that makes this functionality possible. Maybe
somebody with more system experience can tell if this is compiled into whatever
libraries lxml is using. I think these extensions have been around for years,
so I'd not suspect some sort of version mis-match right away.
https://gitlab.gnome.org/GNOME/libxslt/-/blob/master/libexslt/crypto.c
I'd love to have these hash functions available easily, or know that we
definitely have a difference between the two processors.
Thanks,
Rob