OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] trouble with footers


Ah, got it. This works:
 
<xsl:template match="/d:book/d:info/d:releaseinfo" mode="book.titlepage.footer">
  <xsl:apply-templates />
</xsl:template> 
 
with
 
<xsl:when test="$position = 'center'">
  <xsl:apply-templates select="/d:book/d:info/d:releaseinfo" mode="book.titlepage.footer"/>
</xsl:when>
 
Damon
 
On Sat, 09 May 2009 08:46 +0100, "Damon Mannion" <damon@mannion.me.uk> wrote:
 
Thanks, Bob, all makes sense and extremely helpful.
 
Only item I didn't quite understand is how to create a new titlepage 'footer' mode to handle the rendering of the releaseinfo element.
 
My guess is something like this:
 
<xsl:template name="titlepage" mode="titlepage.footer">
  <xsl:apply-templates />
</xsl:template>
 
with
 
<xsl:when test="$position = 'center'">
   <xsl:apply-templates select="/d:book/d:info/d:releaseinfo" mode="book.titlepage.footer"/>
 </xsl:when>
 
but I can't seem to get it to work, and have tried various different names/paths, and to be honest this doesn't seem right to me.
 
I'm using a customised titlepage, and looked to see whether there is a way to create the right mode within the titlepage.xml, but couldn't see a way to do this.
 
Damon
 
 
On Fri, 08 May 2009 11:56 -0700, "Bob Stayton" <bobs@sagehill.net> wrote:
 
Hi,
I presume your simple document's root element has the namespace declaration xmlns="http://docbook.org/ns/docbook", and that you are using the docbook-xsl-ns namespace aware stylesheets, correct? 
 
A1: The preferred way is with xsl:apply-templates in most cases.  That way any child elements are processed with their templates.  When you use xsl:value-of, it returns only the text strings within the element, ignoring any element markup, and you lose such things as subscript positioning and generated trademarks. 
 
There are a few situations where you must have text only, such as when you are computing an attribute value such as alt which cannot contain markup elements.  Even then, I usually use apply-templates inside a variable, and then take the value-of of the variable.  That way any generated text is included.
 
Back to your question, many of the elements in info don't have templates in the default mode (no mode), only in mode="titlepage.mode". That is the case with releaseinfo.  Fortunately, the titlepage.mode works outside of titlepages too when it is applied. You could also create a new template in a new mode, such as mode="footer.mode", and apply that mode if you need different behavior.
 
A2: The date element does have a template in default mode, in fo/inline.xsl.  I think that's because date also appears in revhistory, and revhistory can appear in lots of places outside of titlepages.
 
A3: The default mode is generally used to process the content of a document in document order. But info is one of those elements that contains metadata, and is generally not meant to be processed in document order. The titlepage spec file exists to rearrange or omit elements in info.  The default mode template for info is empty to prevent it from being accidentally processed in document order:
 
    <xsl:template match="d:book/d:info"></xsl:template>
Modes are used to process elements outside of document order, such as in a toc and titlepage.
 
A4: answered in Q1.
 
A5: The difference is the context from which the template is applied.  The titlepage and toc are generated by the template with match="d:book", so the current context element is <book>, and so a relative path such as "d:info/d:releaseinfo" works relative to that context.  A chapter is generated by the template with match="d:chapter", so the current context elements is <chapter>, and now a path relative to the chapter would look for d:chapter/d:info, which probably doesn't exist in your document. 
 
To get at the book's info element from all contexts, you need a full XPath:
 
   select="/d:book/d:info/d:releaseinfo
 
Hope this helps.
 
Bob Stayton
Sagehill Enterprises
bobs@sagehill.net
 
 
----- Original Message -----
Sent: Friday, May 08, 2009 6:58 AM
Subject: [docbook-apps] trouble with footers
 
Hi
 
Some newbie questions below. I have been battling with getting the document info elements working in the footer, and have hit a number of dead-ends. I suspect my questions and all related, and my lack of understanding underpins them all.
 
 
I have a simple document:
 
<book>
  <info>
    <date>2009-03-29</date>
    <releaseinfo><trademark class="registered">CompanyName</trademark> Ltd 2009, all rights reserved.</releaseinfo>
 
 
and want parts of the document info elements to appear in the footer, so:

<xsl:when test="$position = 'left'"> 
  <xsl:value-of select="d:info/d:date"/>
  <fo:block/>
  <xsl:apply-templates select="d:info/d:date"/>
</xsl:when>
 
Q1 - which is the preferred way of doing this, value-of or apply-templates?
 
 
However, when I pull into the release info into the footer using apply-templates, I get the following compile error:
 
"Element releaseinfo in namespace 'http://docbook.org/ns/docbook' encountered in info, but no template matches."
 
I can get around this by specifying a mode parameter, but I am not sure what mode to be setting.
 
Q2 - why does releaseinfo behave differently to date?
Q3 - if apply-templates is the right way of doing this, then should there be a mode setting, if so what/why?
 
 
Then something strange happens with how the releaseinfo is displayed, with this setup in the footer:
          <xsl:apply-templates select="d:info/d:releaseinfo"/>
          <fo:block/>
          <xsl:value-of select="d:info/d:releaseinfo"/>
 
The apply-templates line produces this output:
"<releaseinfo>CompanyName® Ltd 2009, all rights reserved.</releaseinfo>"
 
and the value-of produces this output:
"CompanyName Ltd 2009, all rights reserved."
 
Q4 - why does the value-of lose the registered trademark?
 
 
Finally, the footer output for date and releaseinfo appear on the titlepage and toc, but as soon as the main body of the document (i.e. chapter 1 on) starts, the output from date and releaseinfo do not appear in the footer at all.
 
Q5 - why does the behaviour change at the point, and how to resolve?
 
 
Thanks for any help/pointers.
 
 
Damon
 


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]