Re: [xsl] local variables as entity reference in different stylesheets

Subject: Re: [xsl] local variables as entity reference in different stylesheets
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 3 Dec 2001 19:41:59 +0000
Hi Marko,

> In stylesheets a.xsl, b.xsl and c.xsl I use the same local variables
> (not top-level, but inside templates). I think the easiest way to do
> this, is to make use of 'variables.xsl' as an entity-reference
> (&variables;). In fact, this is the way I do it. The only ugly thing
> about it, is that I have to put
> "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'" into each
> variable, because I can't think of a suitable root element.

I'm surprised that your dummy root element works. Variable definitions
are only in scope to their following *siblings* and their children - I
would have thought that having a root element in your entity document
would mean they weren't in scope for the rest of the template. Plus of
course it means you add a root element to your result tree, which
probably isn't what you want.

Or perhaps you're pointing to them using a fragment identifier or
something? Possibly you could declare the name attribute of
xsl:variable to be an ID attribute and then use #name in entity
declarations to access the xsl:variables individually.

Personally, I'd think about introducing named templates that are
shared across the three XSLT documents and collect what you want them
to collect, so for example have the variables defined with:

  <xsl:variable name="attributes">
    <xsl:call-template name="list-attributes" />
  </xsl:variable>
  <xsl:variable name="attributevalues">
    <xsl:call-template name="list-attributevalues" />
  </xsl:variable>

which would give you less incentive to use entities.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread