This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [docbook-apps] Import vs include


Well, your mail prompted me to reread the XSLT spec with regard to import
precedence.  In your situation you have  three templates named
'book.titlepage.separator'.  The first one is in the stock
titlepage.templates.xsl included with the distribution.  The second one is
in your titlepage-html.xsl module that you generated from the spec file.
The third one is in your main customization file  pdf-ps-a4.xsl .
According to the spec:

"It is an error if a stylesheet contains more than one template with the
same name and same import precedence."

When you use xsl:include href="titlepage-html.xsl", that is equivalent to
putting the content of that file into your main customization file. So the
'book.titlepage.separator' template in titlepage-html.xsl and the one in
pdf-ps-a4.xsl  are at the same import precedence, and so they generate an
error.

When you use xsl:import href="titlepage-html.xsl", that will work as long as
it is placed after the import of the main stylesheet file. The part of the
spec that I had forgotten was that if you have two xsl:imports in the same
importing file, the templates in the second imported file have higher import
precedence than the templates in the first imported file.

So this arrangement in  pdf-ps-a4.xsl is better:

<xsl:import href="html/docbook.xsl"/>
<xsl:import href="titlepage-html.xsl"/>
<xsl:template name="book.titlepage.separator">

The original 'book.titlepage.separator' template that was xsl:included into
html/docbook.xsl has the lowest import precedence, because it is imported,
and because it is imported *first*.  The 'book.titlepage.separator' that you
generated from the spec file into titlepage-html.xsl has higher import
precedence than the original template because it is imported second.  But it
has a lower import precedence than the one in  pdf-ps-a4.xsl  because it is
imported, and the one in psf-ps-a4.xsl is not imported.

In summary, it is better to use xsl:import on the generated titlepage
templates file.  You can use xsl:include only if you don't further customize
any of the titlepage templates.  I need to fix that example in my book.

If you want to read what the spec says about import precedence, see:

http://www.w3.org/TR/xslt#import

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net


----- Original Message ----- 
From: "Michèle Garoche" <michele.garoche@easyconnect.fr>
To: "Bob Stayton" <bobs@sagehill.net>
Cc: <docbook-apps@lists.oasis-open.org>
Sent: Monday, April 11, 2005 12:22 AM
Subject: Re: [docbook-apps] Import vs include

Le 11 avr. 2005, à 7:41, Bob Stayton a écrit :

> Does pdf-ps-a4.xsl  consist *only* of the import statement and the
> include
> statement, or does it also contain other customizations, including a
> template named 'book.titlepage.separator'?
It contains also other customizations and this:

<!-- First bookmark points to second page of cover -->
<xsl:template name="book.titlepage.separator">
</xsl:template>

to correct the page where first bookmark points (i.e. a blank page).

Michèle
<http://micmacfr.homeunix.org>



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]