Before delving into the XSLT2.0 specification I was hoping to see some
form macro definition added to the specification.
Even though Named Templates and functions are supported it would be
nice to be able to create new instruction elements in XSLT. So instead of
invoking the rather verbose
It would be nice to define a macro that could be invoked as an XSLT
instruction, for instance:
<ns:doSomething arg1="1" arg2="2"/>
Or go even further and define macros that accepts nested macros, etc.
(see FreeMarker for some ideas)
Any ideas as to how such a generic macro could be built on top of Saxon
as XSLT2.0 does not seem to support it?
Is this even possible to be implemented as a generic extension instruction in Saxon?
I dont have much experience with writing extension elements, but I would be willing to give it a shot and possibly even contribute that back to Saxon, if there is an interest.
If you're interested in doing this, I would think the most promising route is a preprocessor, which translates the "macros" (extension instructions) into named template calls. I think you could write this in XSLT.
I was thinking of doing this a while ago before we had stylesheet functions. It would be nice in some ways, but it's not clear to me that there's room for yet another mechanism alongside templates and functions, especially if it's not part of the language spec. On the other hand, xsl:function came originally from saxon:function, which was provided as a way of writing extension functions in XSLT, and one could argue that there's just as good a case for being able to write extension instructions in XSLT.