Re: [xsl] Stylesheet parameters and packages?

Subject: Re: [xsl] Stylesheet parameters and packages?
From: "David Birnbaum djbpitt@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 10 Jun 2020 16:45:37 -0000
Thanks, Michael. I followed Martin's advice and declared the $debug
parameter only in the lower-level package, and it does, indeed, work as
expected both within that package and in others that import it. In
non-package-based XSLT I normally set $debug as static, and since I
normally compile and execute as one step (as opposed to compiling
separately and saving an SEF), I can override setting that at the command
line. If I've understood correctly, if I want to pre-compile the package
and save the SEF, I would not be able to reset a static parameter, and that
may become important at a later point.

The situation you describe ("If package A uses B and C, and if there's a
$debug parameter in both B and C") did raise an error. Creating separate
debug parameters for each package, with different names, works around that,
at the cost of having to manage the different values, whether with a
variable (as you propose) or by setting them separately on the command line
at run time. Since there are situations where I may want debug information
from only one package (e.g., from the importing one, which I'm developing,
but not the imported one, which I've already debugged), the ability to set
the values separately for the different packages could be useful
functionality.

Since you ask for shared experiences: The limitation of packages that I
find most inconvenient at the moment is that XSpec cannot yet deal with
them, and I haven't found a good alternative for test-based development of
packages. The last update of the open issue in the XSpec repo is dated
April 10, 2020 (https://github.com/xspec/xspec/issues/762), There's an
approved pull-request currently waiting (for about a week) to be pulled at
https://github.com/xspec/xspec/pull/892, so that limitation seems likely to
go away, and I'll try it and report back when it becomes available in the
master XSpec branch.

On Sun, Jun 7, 2020 at 5:55 PM Michael Kay mike@xxxxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> I'm afraid asking for a "rule of thumb" is over-optimistic; as always, the
> devil is in the detail.
>
> For a $debug option you need to decide whether you want a static parameter
> or a dynamic parameter (do you want users to be able to switch debugging on
> at execution time, or must it be built-in at compile time?
>
> Static parameters do have some limitations and there are some
> inconsistencies in the spec: see https://github.com/w3c/qtspecs/issues/5.
>
> Do you need to enable debugging at the package level, or is it a global
> option?
>
> If package A uses B and C, and if there's a $debug parameter in both B and
> C, then I think you're going to get a conflict, because both are visible in
> A. I think you can tackle that by having two parameters $debug-B and
> $debug-C with different names, and have overriding xsl:variable's in A that
> setsthe value of both to the value of parameter $debug-A.
>
> But to be honest, there's not much practical experience yet of developing
> with XSLT 3.0 packages; you're pioneering here and I hope you'll share your
> experiences as a contribution to shared understanding.
>
> Michael Kay
> Saxonica
>
> On 7 Jun 2020, at 18:40, David Birnbaum djbpitt@xxxxxxxxx <
> xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Dear xsl-list,
>
> Is there a rule of thumb for managing stylesheet parameters when using a
> package hierarchy, that is, in situations where packages use other
> packages? I would like to set a $debug parameter in all packages, both the
> lowest-level collections of user-defined functions and the higher-level
> packages that import those libraries, and that are then imported,
> themselves, by other stylesheets. But as I fiddle with the options, either
> I am notified by the mid-level package that a parameter has not been
> declared there (even though it is declared in a lower-level package that I
> am using in the mid-level one, and the XSLT 3.0 spec tells me that
> stylesheet parameters are obligatorily public) or, when I declare the
> parameter in the mid-level package, that it conflicts with the lower-level
> declaration. In case this is helpful, the point of the $debug parameter is
> that I want to write diagnostic messages to stderr using <xsl:message>
>  when the $debug parameter value is true, and I need to be able to generate
> messages of this sort from both the low-level and mid-level packages.
>
> Sincerely,
>
> David
> djbpitt@xxxxxxxxx
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by
> email)
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3318727> (by
> email <>)

Current Thread