[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] key declarations in/for included stylesheets


Subject: Re: [xsl] key declarations in/for included stylesheets
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Fri, 20 Jul 2012 08:51:32 +0100

On 20 July 2012 06:20, Trevor Nicholls <trevor@xxxxxxxxxxxxxxxxxx> wrote:
> I have started with an unwieldy stylesheet which I am breaking up into
> smaller stylesheets to facilitate reuse.
>
> The original stylesheet includes the declaration
>
>    <!-- key for cross references -->
>    <xsl:key name="id" match="*[@id]" use="@id" />
>
> and this key is used in three places. I want to take these and move them
> into separate stylesheets which will be xsl:included.
>
> Im not sure what the best practice is here:

It's a common problem, typically with variables or functions defined
elsewhere and imported/included by some ancestor stylesheet so given
just the file you are looking at there's not much to go on.  I think
there are some new features coming in 3.0 that will help here.

My personal preference is to not break up a file for the sake of it.
It's ok to have large XSLT files - if there is a natural grouping to
what you are doing then break them up along those lines, but dont
force it.  I see projects where there are hundreds of small
stylesheets, and entry point stylesheets that are just hundreds of
includes...

In this particular case with keys, if its for reuse elsewhere then you
will need to keep the keep definitions in each of the files they are
used.  If the common parent imports them then its key definition will
be used.  If it includes them then the key definitions will be merged
(you can have multiple definitions of a key with the same name) which
I think will ultimately have the same result as they would be
identical.


--
Andrew Welch
http://andrewjwelch.com


Current Thread
Keywords