|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
unwanted invoke of xsl:template
Really don't understand this, my xsl:template is called when i don't expect it to.
I'm working on lots of xsl files, to generate preformatted letters. These letters have many parts which should be the same allover (headers, footers etc.). So i created a main template which gets included through xsl files to create different letters Code: <xsl:template name="main_1_page"> <xsl:call-template name="standaard_header" /> <xsl:call-template name="details" /> <xsl:call-template name="standaard_footer" /> </xsl:template> Later on i made a second template. <xsl:template name="main_two_pages" > <xsl:call-template name="standaard_header" /> <xsl:call-template name="details" /> <xsl:call-template name="standaard_footer" /> <xsl:call-template name="header_vervolgblad"> <xsl:with-param name="vervolgblad_nr" select="1"/> </xsl:call-template> <xsl:call-template name="details_1"/> An example of file to generate a letter is: <xsl:template match="/"><xsl:call-template name="main_1_page" /></xsl:template> <xsl:template name="details"/> The problem is that this page tries to invoke the "details_1" template WHY??? Thanks in advance Peter Odekerken |
|
#2
|
|||
|
|||
|
It seems to me that <xsl:call-template name="details_1"/>
is at the top level within <xsl:stylesheet> which means (if I'm not mistaken) that it will be called anyway. I don't recommend using calls at the top level, unless you really know what you're doing. And in any case, this is something that shouldn't have to happen there. In correct programming, you'd place this as the first line of your main template if you really needed to. |
|
#3
|
|||
|
|||
|
No,
<xsl:call-template name="details_1"/> is only called from these two templates (depending on the letter which has to be formatted): <xsl:template name="main_1_page" > <xsl:template name="main_two_pages" > So the calling xsl ,simplified, looks like: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"><xsl:call-template name="main_1_page" /></xsl:template> <xsl:template name="details"> Detail stuff here </xsl:template> </xsl:stylesheet> I could send you the files if that helps Thanks in advance Peter Odekerken |
|
#4
|
|||
|
|||
|
You are calling the details_1 template after you close the main_two_pages template. If you are including these templates as seperatate files then details_1 is classifed as being in the root and will always be called.
Later on i made a second template. <xsl:template name="main_two_pages" > <xsl:call-template name="standaard_header" /> <xsl:call-template name="details" /> <xsl:call-template name="standaard_footer" /> <xsl:call-template name="header_vervolgblad"> <xsl:with-param name="vervolgblad_nr" select="1"/> </xsl:call-template> <xsl:call-template name="details_1"/> |
|
#5
|
|||
|
|||
|
Appears to be that the xsl gets sort of compiled.
Meaning if it 'sees' a call:template name="the_name" it tries to find it. I have splitted up the several main templates in different files, and that fixed the problem. Thanks for the kind help Peter Odekerken (obviously <xsl:newbie/> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > unwanted invoke of xsl:template |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|