Subject: [xsl] import, include, and packages? From: "David Birnbaum djbpitt@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 23 Apr 2020 15:36:56 -0000 |
Dear XSL-list, I find myself writing my first importable XSLT function since the advent of XSLT 3.0, and I would be grateful if someone could advise me about best practicebor, at least, about pitfalls of which I should be aware. In the past I have used <xsl:include> and <xsl:import> pretty much arbitrarily. I understand that imported templates have lower priority, but in my environment I don't need to deal with competing priorities, so I have not seen a reason to prefer one of these over the other. If I am overlooking a reason to prefer one or the other when priorities aren't an issue, I would be grateful for advice. Since <xsl:package> is now available, I thought this was an opportunity to learn how to use it. I have read Michael Kay's http://www.xmlamsterdam.com/pdf/2013/2013-michaelhkay-ansterdam.odp, the Saxon documentation for <xsl:package> and <xsl:use-package>, and the corresponding sections of the XSLT 3.0 spec. I am not confident that I have understood all of these fully. In particular: 1. I think the advantage of using <xsl:package> over <xsl:import> and <xsl:include> for my case (importing a single function [but see below about arity]], from a package that does not import anything itself) is that I can expose only the function that I want to expose, and not any other named components of the imported package (variables, helper functions, etc.). If that understanding is correct, it does sound like an advantage. (I want to be able to run the code in Saxon HE, so being able to precompile the package, which would be a benefit under other circumstances, would not be relevant in this case.) 2. I don't understand how (or whether it is possible) to import packages without setting up a configuration file. If it isn't, that would seem to be a disadvantage for my use case, since anyone else who wanted to use my function library would have to set up a configuration, as well., and not just get a copy of the package file itself If I have understood correctly, the spec seems to say that the configuration is implementation-dependent, so if one is needed, where would I find documentation about how to set it up for use by Saxon, both at the command line and inside <oXygen/>? If a configuration setup is not requiredbthat is, if it is possible to specify the file-system location of the imported package directly inside the importing oneb how do I specify the location of the imported package in <xsl:use-package>, given that I would want the path to be relative to the importing stylesheet? Is the procedure for doing that the same as with <xsl:include> and <xsl:import>? 3. On a semi-related topic, I want my function to have one-argument and two-argument versions. Since function parameters cannot be optional, I think a fairly straightforward way to do this would ge to put the code in the two-argument version, and have the one-argument version supply a default for the missing argument and then use it to pass the call along to the two-argument version. Is this the best way to deal with optional function arguments? Thank you all for any advice or guidance you might be able to provide. Sincerely, David David J. Birnbaum, dbpitt@xxxxxxxxx
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Declarative Amsterdam Announc, Erik Siegel erik@xxx | Thread | Re: [xsl] import, include, and pack, Michael Kay mike@xxx |
[xsl] Declarative Amsterdam Announc, Erik Siegel erik@xxx | Date | Re: [xsl] import, include, and pack, Michael Kay mike@xxx |
Month |