You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Frans Germishuizen <fr...@isservices.co.za> on 2007/02/16 09:34:07 UTC

Template Calling help

Hi There
 
I would like to post a question to you:
Ive got a xsl that calls a lot of other templates (<xsl:call-template
name="the_test"). 
The xml has got all the templates in a child node -
<template-name>2nd_test</template-name>.
 
Currently ive got a lot of when statements conditioned to the
<template-name> node, then to call a hard coded template name e.g
<xsl:when test="name='the_test'">
            <xsl:call-template name="the_test">
</xsl:when>
 
What ive tried is:
<xsl:for-each select="/req/page-template-set/page-template">
            <xsl:variable name="template">
                        <xsl:value-of
select="/req/page-template-set/page-template/name"/>
            </xsl:variable>
            <fo:flow flow-name="xsl-region-body">
                        <xsl:call-template name="{$template}"/>
            </fo:flow>
</xsl:for-each>
 
But I get a invalid usage error. 
 
Is there a way where I can do this easier to create a generic
call-template?
 
Thanks
Frans
fransg@isservices.co.za 
 

Confidentiality Caution and Disclaimer

This message and/or any attachment thereto ("the message")
contains privileged and confidential information intended
only for the recipient named above. 
If you are not the intended recipient of this message,
please erase it permanently once you have notified the
sender, per return e-mail, that you have received the
message in error.
Unless the sender is duly authorised by either the Telesure
Group, or any of its subsidiary companies or I.S Services
("the Group") to send this message and unless the content
of this message is also duly authorised by the Group, any
views expressed in this message are those of the individual
sender and the Group will not accept liability therefore,
nor for any consequential damage arising therefrom.
Any recipient of an unacceptable communication, a chain
letter or offensive material of any nature is requested
to report it to postmaster@isservices.co.za.

Re: Template Calling help

Posted by Chris Bowditch <bo...@hotmail.com>.
Frans Germishuizen wrote:

<snip/>

> Currently ive got a lot of when statements conditioned to the 
> <template-name> node, then to call a hard coded template name e.g
> 
> <xsl:when test=”name=’the_test’”>
> 
>             <xsl:call-template name=”the_test”>
> 
> </xsl:when>
> 
>  
> 
> What ive tried is:
> 
> <xsl:for-each select="/req/page-template-set/page-template">
> 
>             <xsl:variable name="template">
> 
>                         <xsl:value-of 
> select="/req/page-template-set/page-template/name"/>
> 
>             </xsl:variable>
> 
>             <fo:flow flow-name="xsl-region-body">
> 
>                         <xsl:call-template name="{$template}"/>
> 
>             </fo:flow>
> 
> </xsl:for-each>
> 
>  
> 
> But I get a invalid usage error.

This is a pure XSLT question. I'm not 100% certain but I think you will 
have to stick with the approach of using a xsl:when because you can't 
dynamically build XSLT using XSLT variables. A similiar problem arises 
when you have a whole bunch of attribute-sets (representing a set of 
styles), and the XML dictates which style should be applied. You can't do

<fo:block xsl:use-attribute-set="{$stylename}">
<xsl:apply-templates/>
<fo:block>

You will be able to get more help on XSLT questions on the mulberry list:

http://www.mulberrytech.com/xsl/xsl-list/


Chris




---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org