Re: [xsl] managing parameters to stylesheets

Subject: Re: [xsl] managing parameters to stylesheets
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Sat, 20 Mar 2004 00:31:12 -0500
Danny,

Does each document have a unique identifier somewhere (for example as an attribute at the top level)?

If so, you could use that to parameterize the values you presently provide at run time: query into your configuration file with this as a key value or XPath predicate.

Instead of passing parameters from template to template, you'd do some kind of lookup whenever you needed the locally-applicable value. You could even do the lookup as a parameter defaulting mechanism.

Assuming your problem can reduce to this (maybe you don't really need to pass parameters through the templates at all), it could be neat and clean, and would scale. And while it might not be super-performant, that might not matter either.

Cheers,
Wendell

At 09:39 PM 3/19/2004, you wrote:
I've been using a setup of stylesheets that take command line parameters (using Saxon) to process a single file into HTML format that is then compiled into MS Help. I used 2 or 3 global parameters to manage things like the where to write the file, how to format, etc.

This process has been working fine because I have had a single document that I want to process. Now I need to process a group of documents into the help format. These documents have sections that should cross-reference each, so processing individually is not an option I want to look at.

My problem is that each document may have a slightly different combination of control parameters. I've started converting my process over to use a configuration file that lists the objects to process and their individual parameters.

In making this conversion I've noticed a major programming change. Where I could just rely upon the parameters being available in the old model, I now have to pass these parameters between templates directly. The problem is that I don't have a template for every level in my document. What happens is if I do not explicitly pass a parameter through a template (called in document order, not by name or anything else) then that template doesn't have access to the parameters value.

What I would at least like to do is convert all my <xsl:apply-templates/> to something like this:

<xsl:apply-templates>
        <xsl:with-param name="dir" select="$dir"/>
</xsl:apply-templates>

If I have a structure like:
        Body
                Sect
                        Div
                                head
                        Listing
                                head

I used to get away with not having to have explicit templates for Div and Listing to have a template for head work just fine.

Any ideas on how to re-arrange things so I don't have to add all these "default like" templates?

I would really like the apply-templates to create its own default template setup where not only do modes get automatically added, how about picking up the set of parameters as well?

Barring that from working, it would be nice to somehow use the <xsl:include> somewhere other than the top of a stylesheet and use document() to specify the include as well as the parameters that should be used for that particular document.

Anyone got another idea for how to tackle this? My current design is going to be very buggy, depending upon how stable the DTD remains in the future.


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread