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] wanting to understand the use of attributes in xsl templates


Hi Geoff,

[I know this reply is over two weeks late, but I am a bit behind
reading this list.  I didn't see any replies to your post, so here's
one.]

On Fri, Dec 02, 2005 at 12:45:25PM +1100, Geoff Purchase wrote:

> Now that I'm trying to achieve the same result for my PDF output,
> things are a bit different.  The default template for <phrase> in
> fo/inline.xsl is:
> <xsl:template match="phrase">
>  <xsl:call-template name="inline.charseq"/>
> </xsl:template>
> 
> If I create a new template in my customisation layer as:
> <xsl:template match="phrase[@role='red']">
>  <fo:inline color="red">
>    <xsl:apply-imports/>
>  </fo:inline>
>  <xsl:call-template name="inline.charseq"/>
> </xsl:template>
> 
> I get the text wrapped in <phrase role="red"> as red text *and* the
> same text in black.  Removing the call to inline.charseq seems to
> work.

That's exactly the expected behaviour here.  The 'xsl:apply-imports'
looks for a matching template in the set of templates you've imported
with your customisation layer---that is, the standard DocBook XSLT
templates.  In this case, it matches on 'phrase' alone (since there's
no more specific template in the standard XSLT).  As you've noted
above, that template contains a call to the 'inline.charseq' named
template, and it's this template that emits the text between your
'fo:inline' tags.  You're then calling it again, so it emits the text
again, this time unadorned and hence in black.  As you note, removing
your additional call to this named template fixes the problem.  There
is nothing unexpected here.

> Question 1.  If I have 
>    <para>Blah blah <phrase role="red">some text</phrase> blah
>    <phrase>other text</phrase>.</para>
> will the first <phrase> only call the template that has
> [@role='red'] or will it call both templates?

It is always the case that only the most specific matching template is
called.  If you have a template for 'phrase[@role="red"]', then that's
the one which will be matched by the first 'phrase' above.  If you had
an element 'phrase role="foo"', but didn't have a corresponding
template, then the 'phrase' template would match instead.

> Question 2.  What named colours are supported by FOP?  For my html
> output I'm using CSS with the basic 16 named colours (aqua, black,
> blue, fuschia, etc) and I would like to use the same names in my PDF
> output.

This I don't know.  Check the FOP website.

> Question 3.  Assuming everything will work as I hope, how do I
> reference the role attribute as a variable instead of creating 16
> almost identical templates (1 for each colour)?

One solution would be to do this:

<xsl:template match="phrase[@role='red']|phrase[@role='blue']|...">
  <fo:inline color="{@role}">
    <xsl:apply-imports/>
  </fo:inline>
</xsl:template>

Having said all of that, I've just got to ask: why?  Why do you want
to fix presentation-level characteristics in your semantic markup?
(Obviously, I have no idea what you're writing, and there may be a
very good reason for doing it this way.)


-- 
Paul.

w  http://logicsquad.net/
h  http://paul.hoadley.name/

PGP signature



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