Next in thread →
Next in month →
Re: [docbook-apps] Extending XSL stylesheets to match extended DTD
I can give you some general guidelines and hints
for creating a stylesheet customization for new elements.
First, find elements whose format most closely
resembles what you want for output, and copy those to your customization layer,
changing the match= attribute to your new element name, and adding any new steps
you want to the processing.
Most (but not all) templates in DocBook XSL use a
general <xsl:apply-templates/> to process all their children. If you
have a match attribute on a template for a new element in that context, it
will get used in those circumstances.
But there are a few situations where elements are
selected by name, in order to present them in a specific sequence. In
those cases, a new element's template might not get called unless you customize
the calling template to add your element to the list. The worst case of
this kind of processing is the computation of Next and Previous links in chunked
HTML output. See for example the template named "chunk-all-sections" in
html/chunk-code.xsl. Those templates use long lists of element names in select
attributes to figure out the next chunk.
If you want to actually chunk HTML on one of your
new elements, be aware that the stylesheets aren't easy to customize for that
purpose. The previously mentioned Next and Previous computation shows
why. You have to add your element name to several locations to include
it.
Many elements are processed in more than one XSL
mode, so you'll need to also add templates for those modes if appropriate.
For example, if you want an element to appear in the table of contents, you may
need a mode="toc" template. If you want to cross reference to an element,
then you need a mode="xref-to" template. An element with title might
need a mode="title.markup" template.
If any of your new elements is to generate text
labels or titles, then you will want to add gentext elements to the
'local.l10n.xml' parameter (it is a parameter, not an XML file). You might
need to add a general <l:gentext> element, as well as <l:template>
elements in the contexts of title and xref.
Those are some general suggestions. If you
want to select a couple of your new elements and describe how you want them
handled, we could have a more detailed discussion.
Bob Stayton
Sagehill Enterprises
DocBook Consulting
----- Original Message -----
From:
Cameron
Kerr
To:
Sent: Tuesday, November 14, 2006 3:25
PM
Subject: Re: [docbook-apps] Extending XSL
stylesheets to match extended DTD
The schedule is only one part of a much larger work.
I think the DocBook XSL book could do with a larger worked example that
doesn't rely on the availability of appropriate parameters.
On 14/11/2006, at 10:15 PM, Bob Stayton wrote:
Hi Cameron,
Maybe I'm missing something
myself, but I'm not clear on how DocBook is helping you much here. I
see very little usage of DocBook elements in your documents. I
understand that you might want to use the DocBook stylesheets because they
are pretty versatile, but you may have more customization to do than if you
just wrote XSL templates from scratch for your purposes. You could
always borrow some DocBook templates for the lower level elements like para
and such.
Bob Stayton
Sagehill Enterprises
DocBook Consulting
----- Original Message
-----
From:
Cameron
Kerr
To:
Sent:
Monday, November 13, 2006 12:20 PM
Subject:
[docbook-apps] Extending XSL stylesheets to match extended
DTD
Hello, I'm trying to work out precisely what would be
required in extending the DocBook DTD in order to produce a significant
amount of coursework.
As part of this, I want to mark up a curriculum/schedule. This would
be comprised largely of block elements, such as the following structure
indicates.
schedule
week*
lecture*
title
presenter?
topics?
topic+
para
etc.
themes?
theme+
para
etc.
laboratory*
title
marks?
topics?
topic+
para
etc.
tutorial*
title
marks?
readings?
reading+
para
etc. (needs work
to profile book editions)
I have a rough idea of what I need to do to create a customisation
layer for the DTD, but none of the books I've consulted (including Docbook
XSL) mention anything (that I could find at least) about the correct way
to make a stylesheet extension.
Any tips? Or have I managed to miss something completely
obvious?
--
• Cameron Kerr • ✉ • •
• Telecommunications Teaching Fellow & SysAdmin •
• ✎ http://humbledown.org/blog/ • ✆ 021 02 333
294 •
--
• Cameron Kerr • ✉ • •
• Telecommunications Teaching Fellow & SysAdmin •
• ✎ http://humbledown.org/blog/ • ✆ 021 02 333
294 •
Next in thread →
Next in month →