RE: [xsl] Optimization issue with includes and attribute-sets

Subject: RE: [xsl] Optimization issue with includes and attribute-sets
From: "Angela Williams" <Angela.Williams@xxxxxxxxxxxxxxxxxx>
Date: Mon, 29 Jan 2007 14:36:42 -0600
Thank you for the explanation.  I was sure I was the one in error, but
not sure how to resolve it.

You mentioned attribute sets are rarely used. What would be the
preferred alternative?  (We have a 25,000 line stylesheet to produce
account statements that I have been tasked to re-write to be more
modular and efficient.  The stylesheet heavily depends upon attribute
sets to format the statements.  In addition, the stylesheet contains a
lot of content that must be stripped and abstracted for a content
management system.)

Thanks!
Angela

-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: Monday, January 29, 2007 2:23 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Optimization issue with includes and attribute-sets

Saxon is doing pretty well exactly what the spec says it should do:
you've
included the module containing the attribute set twice, so you have two
different attribute sets with the same name, and when you do
use-attribute-sets, all attribute sets with the given name are processed
and
hte results are merged. Saxon could optimize this, but attribute sets
are
used so rarely that they don't get much attention as far as performance
is
concerned. (At one time I was planning to do all the merging of
attribute
sets at compile time, but I decided to wait until I saw a real user
need: it
didn't seem worth the risk of introducing bugs.)

The simplest solution is to only include attributes.xsl once. You can
include it from anywhere, and the named attribute sets will be available
everywhere, not only in the including module.

For a more sophisticated solution see the Note in section 3.10.2 of the
spec:

Note:

It is not intrinsically an error for a stylesheet to include the same
module
more than once. However, doing so can cause errors because of duplicate
definitions. Such multiple inclusions are less obvious when they are
indirect. For example, if stylesheet B includes stylesheet A, stylesheet
C
includes stylesheet A, and stylesheet D includes both stylesheet B and
stylesheet C, then A will be included indirectly by D twice. If all of
B, C
and D are used as independent stylesheets, then the error can be avoided
by
separating everything in B other than the inclusion of A into a separate
stylesheet B' and changing B to contain just inclusions of B' and A,
similarly for C, and then changing D to include A, B', C'.

Michael Kay
http://www.saxonica.com/

Current Thread