logo       

Re: extension element that creates instructions: msg#00170

text.xml.saxon.help

Subject: Re: extension element that creates instructions

Also, use

saxon:call-template

The saxon:call-template instruction is identical to xsl:call-template except that the template name can be written as an attribute value template, allowing the actual template that is called to be selected at run time.

Typical usage is:
<saxon:call-template name="{$tname}"/>


HTH,
Roger Kovack

Andrew Welch wrote:
I want to write my own Saxon extension that creates XSLT 
instructions. The extension should load additional XSLT code 
from an external systems 
(e.g. a database); this imported code should be interpreted 
as well. Is 
this possible?

While writing, another idea comes to my mind: maybe it is 
easier to use 
an import statement in the stylesheet that loads via a special 
URIResolver a new stylesheet that contains only a named template with 
the code from the external system. This named template could then be 
called instead of using an extension.

So far I have only written simple extension, so is the first approach 
possible at all? Or is the second approach with the import better?
    

Instead of writing a stylesheet that calls an extention function to
condionally return a template, put all of your conditional code into
individual stylesheets that import the common stylesheet.  For example:

Stylesheet 1.
<xsl:import href=""/>
<xsl:template name="abc">
	<xsl:value-of select="'from stylesheet 1'"/>
</xsl:template>

Stylesheet 2.
<xsl:import href=""/>
<xsl:tempate name="abc">
	<xsl:value-of select="'from stylesheet 2'"/>
</xsl:template>

Common.xsl
<xsl:template match="/">
	<xsl:call-template name="abc"/>
</xsl:template>

Here whichever language is controlling the transform (java I assume)
uses the conditional logic to select stylesheet1 or stylesheet2 as the
primary stylesheet.  Then at the point in the stylesheet where you would
call out to the extension function just use a normal call-template which
will call the named template in the top-level stylesheet.  I hope that's
clear from the brief explanation.

cheers
andrew


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&opÌk
_______________________________________________
saxon-help mailing list
saxon-help-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/saxon-help


  
------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise