Subject: RE: [xsl] xsl:call-imports?|
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 25 Oct 2004 18:15:01 +0100
It's a rational idea, but you can achieve the same effect by using a match template with say match="*" and some special mode, and simply not using the node that it happens to match on. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Mario Caprino [mailto:mariocaprino@xxxxxxxxxxx] > Sent: 25 October 2004 17:18 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] xsl:call-imports? > > Hi, > > I'm structuring my XSLT stylesheets and find myself missing an > <xsl:call-imports> element. I feel I need such an element > for the exact > same reason that <xsl:apply-imports> is so usefull. > > My specific case for wanting such an element is; > My main stylesheet includes all my default templates. For > the language > specific versions of the stylesheet I would like to send the language > specific text as parameters to the default template. > > Heres an example; > > __default.xsl__: > > <!-- main template --> > <xsl:template match="/"> > ... > <xsl:call-templates name="facts" /> > ... > > <xsl:apply-templates /> > </xsl:template> > > > <!-- default implementation of "facts" --> > <xsl:template name="facts"> > <xsl:param name="h" /> > <html:div class="shadow"> > <html:div class="facts"> > <html:h2><xsl:value-of select="$h" /></html:h2> > <html:p>...</html:p> > </html:div> > </html:div> > </xsl:template> > > As you see the default template contains alot of tags I would > like to avoid > copying around for each language version, and minimal > language specific text > to insert. I would now like to write in my langugae specific > stylesheet the > following code; > > > __en-UK.xsl__: > > <xsl:import href="default.xsl" /> > > <xsl:template name="facts"> > <xsl:call-imports name="facts"> > </xsl:with-param name="h" select="'Did you know...'" /> > </xsl:call-imports> > > But without any <xsl:call-imports> I need to find > alternatives to accomplish > this; > > 1) Use template match and apply-imports instead. In my case > this will not > work as I am creating the surrounding elements to the page > content, thus it > doesn't fit with a particular tag in the source document. > > 2) Using global variables and overide those. This gets quite > messy once the > stylesheet gets bigger. > > 3) Give different names to the language specific and the > default template. > In my case it does not make sense to call the default template except > through the language specific template, thus it might be the best > suggestion. > > I still feel a <xsl:call-imports> element would be the _best_ > solution, and > do not see why it is not included is XSLT. Is it because I > am trying to use > XSLT in a inappropriate fashion? > Am I overlooking any other alternative for solving my > problem? What would > you do to solve the above mentioned problem? > > Thank you for your help. > > Best regards, > Mario Caprino > > _________________________________________________________________ > MSN Hotmail http://www.hotmail.com Med markedets beste > SPAM-filter. Gratis!