Subject: RE: using xsl:call-template dynamicly
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 21 Apr 2010 14:18:10 +0100
|
This definitely looks like a case for apply-templates.
Instead of a named template name="printListSales", have a template rule
<xsl:template match="element[normalize-space(.)='printListSales']">
and similarly for the other possible values,
and then do
<xsl:apply-templates select="element"/>
and it will choose the right one.
Regards,
Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay
> -----Original Message-----
> From: Red Light [mailto:skydelta98@xxxxxxxxx]
> Sent: 21 April 2010 13:16
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: using xsl:call-template dynamicly
>
> Hi Michael,
>
> "You're using Saxon extensions here, so it's a Saxon question
> rather than a general XSLT question"
>
> sorry for that , in fact i would prefer a general xslt
> solution too(to avoid comment for my boss :d ).
>
>
>
> what i'm tryng to do :
>
> i generate a pdf report true(apache fop) i transform a xml
> source of data to pdf.
>
> in my pdf report i have (sub-section), each sub-section could
> contain one or many pages.
>
> i want to automate the printing:
> for example: i got a main xsl template file (where i import
> the sub-section):
>
> main.xsl:
> -->draw_sales.xsl
> -->draw_bills.xsl
> ....
> ....
>
> in the top of my main.xsl i import the sub_file like:
>
> <xsl:import href="draw_sales.xsl"/>
> <xsl:import href="draw_bills.xsl"/>
>
> and in this draw_sales.xsl:i got something like:
>
> <xsl:template match="printListSales">
> ...............
> </xsl:template>
>
>
> now late consider that in my source xml file i add en element:
> <sectionToDraw>
> <element>
> printListSales
> <element>
> <element>
> printListBills
> <element>
> .....
> <sectionToDraw>
>
> (i added just an example file )
>
>
> and i want to automate the calling of the xsl function that
> are included in the template ; so i don't have to edit the
> main file each time ('m designing an application that gonna
> be used for a third part and i need to automate the
> call-template call)
>
>
> so basicly in my main xsl file
>
> i want to do loop
> and call:
> <xsl:call-template name="{$var1}" ></xsl:call-template>
>
>
> how could i achieve that because xsl:call-template need a QNAME
>
> and thanks for your help
|