logo       

RE: extension element that creates instructions: msg#00169

text.xml.saxon.help

Subject: RE: extension element that creates instructions


> 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="common.xsl"/>
<xsl:template name="abc">
<xsl:value-of select="'from stylesheet 1'"/>
</xsl:template>

Stylesheet 2.
<xsl:import href="common.xsl"/>
<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=click


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise