xsl-list
[Top] [All Lists]

RE: Extending Xhtml2fo.xsl to handle CLASS attributes

2002-12-17 07:57:24
In brief: how can I call a named template, where the name of the template I
want to call is stored in a variable?

In detail:

I have the following XHTML tag:

<span class="symbol">|</span>

When I view this tag in Internet Explorer, the behavior that is associated
with the "symbol" class translates the "|" character into a right-pointing
arrow (looks better than a "greater than" symbol in  strings like "Start >
Programs > ...").  (Actually, the behavior replaces the <span> tag with
"<span style=""font-family: Arial;"">&#9658;</span>".)

I want to do something similar in XSL (starting with the same XHTML tag).
I'm thinking that the best way to do this is via named templates.

Specifically, I'd like to "bolt on" a template name (as an attribute) to the
syntax I've developed for converting class attributes to style attributes.
For example (see the "span.symbol" rule):

<css:stylesheet>

        <rule selector="span.note">font-weight: bold;</rule>
        <rule selector="span.normal">font-weight: normal;</rule>
        <rule selector="span.symbol" template="process-symbol" />

</css:stylesheet>

I want to use the value of the template attribute to call a named template.
Trouble is, it looks like the name you specify in an <xsl:call-template> tag
must be the literal name of the template (not a string expression whose
result is the name).

I've been trying to specify:

<xsl:call-template name="$rule[(_at_)template]">

(where $rule is the <rule selector="span.symbol"> tag, from the listing
above)

but Saxon gives me the error:

No template exists named $rule[(_at_)template]

How do I do this?

Graham Hannington

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>