Shouldn't you use import instead of include?
> -----Original Message----- > From: David Perkowski [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 27, 2002 4:23 PM > To: [EMAIL PROTECTED] > Subject: Named template conflict resolution changes? > > > Hello, > > I have been using an older version of Xalan and finally needed some of > the newer features, so I decided to stick in the latest (2.3.1) Xalan > and get my application running. However, I ran into a problem with the > way named templates of the same name are handled. > > As I understand the W3C spec (XML 1.0 and 1.1wg seem not to differ on > this), importing a template with the same name from another file is > kosher. > > I am using Xalan, in this case, to do templating for a web > application. > Here is my example: > > A.xsl: > --------- > <?xml version="1.0"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > > <xsl:include href="Base.xsl"/> > > <xsl:template name="page-name">Special Page!</xsl:template> > > <xsl:template name="page-content"> > Hello! > </xsl:template> > > </xsl:stylesheet> > --------- > > > Base.xsl: > --------- > <?xml version="1.0"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > > <xsl:template name="page-name">Generic Page.</xsl:template> > > <xsl:template match="/"> > <html> > <head> > <title> > <xsl:call-template name="page-name"/> > </title> > </head> > <body> > <xsl:call-template name="page-content"/> > </body> > </html> > </xsl:template> > > </xsl:stylesheet> > --------- > > > With Xalan 2.3.1, this produces a TransformerException: > javax.xml.transform.TransformerException: java.lang.RuntimeException: > ElemTemplateElement error: Found more than one template > named: page-name > > This used to work with whatever old version of Xalan I was using (I > don't know how to identify the version from the jar file, and I don't > remember which version I used). You can see that what I want is > "overrideable named templates." > > Here is why I think it should work the way it seems not to, currently > (from the W3C XSLT spec): > > Excerpt section 6, Named Templates: > It is an error if a stylesheet contains more than one > template with the same name and same import precedence. > > Excerpt section 2.6.2, Stylesheet Import: > For example, suppose > * stylesheet A imports stylesheets B and C in that order; > * stylesheet B imports stylesheet D; > * stylesheet C imports stylesheet E. > Then the order of import precedence (lowest first) is > D, B, E, C, A > > Which would suggest that A.xsl, because it imports Base.xsl, has the > higher precedence, and that the template named "page-name" should be > used from A.xsl, and that there is no conflict because the > templates do > not have the same import precedence. > > I am making the assumption that it is NOT an error if a stylesheet > contains more than one template with the same name and > DIFFERENT import > precedences, because that is how it used to behave. (and the section 6 > statement wouldn't really mean much if it weren't supposed to > work that > way) > > Is there some option I can set to get this behavior back? I'm going > through my stylesheets and removing double inclusion when I can, but > there are some places where I am using this "template override" for > something meaningful. > > Thanks! > > David Perkowski > e.thePeople >
