Add f:resource() for adding resources from XSLT#2062
Conversation
e56c19c to
32054c0
Compare
|
Just realised I could make it quite simpler, after reading more carefully the documentation of XML::LibXML::NodeList. Right now, you cannot quite call |
|
Using perl extension functions in the XSLT makes me a bit leary (I may have had problems with them in the past?), and I'm trying not to be too tied to libxslt. Is there a difficuilty getting the appropriate |
I see two difficulties, (1) a stylesheet cannot generate |
|
I guess that you case (1) is really the question I was asking: What are the scenarios where you'd not have been able to add |
Ah, I see, good question. My concern is about my BookML users who still use latexml and latexmlpost directly. For them, I need to have all additional CSS resources added during the latexml phase, which is time consuming, and one has to compile the XML file again to change styles. Postprocessing would be the ideal phase for those bits. Another hack in BookML is that I have to fudge the mime type with additional info, like Still, modifying the XML file between the phases is not impossible and the mime type hack is reliable enough, it just needs to happen outside of the LaTeXML workflow. |
|
All else equal, the idea is a nice one. The main problem is that I have circumstances where the same stylesheets have to work under different XSLT (eg. saxon). So, I'm fishing for some not-quite-as-elegant solutions. At least the common stuff, |
Interesting, that's a tricky one. How does saxon deal with In practice: let me add a dummy |
32054c0 to
ba18668
Compare
ba18668 to
5aed67c
Compare
|
Interesting, so now if one inadvertently uses |
Yeah, the code is simple, but finding the right semantics not so much. It could be:
Approach 1. is virtually equivalent to |
Fix #2060: implement a function
f:resource()that copies the desired file and returns the relative path in the site directory. This is meant to be used in XSLT as e.g.It is just a thin layer over
copyResourceand for instance accepts an extra argument for the mime type, which triggers the usual special behaviour for Javascript and CSS.Incidentally,
f:resource()can in principle shift the entireltx:resourcemechanism from Perl to XSLT: if the templates forltx:resourcecallf:resource(), then the special code@resnodes = $doc->findnodes('//ltx:resource[@src]')inprocessbecomes redundant.Note that
register_functionis called once for every document being processed, because it needs to capture the variable$doc. This seems to be fine for LibXSLT, and probably the indended use, since there is nounregister_function.