|
Subject: Re: [xsl] How to use multiple xsl:import From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Wed, 6 Apr 2005 21:19:13 +1000 |
On Apr 6, 2005 9:50 AM, Pieter Reint Siegers Kort
<pieter.siegers@xxxxxxxxxxx> wrote:
> > Since the two xsl:apply-imports are in the same template, they will follow
> exactly the same search path in looking for the next template to apply.
>
> This makes sense.
>
> > If you want to search different sets of templates in the two cases, the
> mechanism to use is modes.
>
> This not... how do I use mode on xsl:import? AFAIK mode belongs to
> xsl:template and xsl:call-templates... please explain!
This makes perfect sense. Let's take an example:
If the imported stylesheet contains a template, which matches an
element named "foo" and the importing stylesheet contains a template
matching node(), at the instruction:
<xsl:apply-templates select="foo"/>
the template from the importing stylesheet will always be selected
over the one from the imported stylesheet as the former has a higher
import precedence.
The only way to ensure that the wanted template from the imported
stylesheet will be selected is to specify it with a unique mode and
change the xsl:apply-templates to:
<xsl:apply-templates select="foo" mode="fooprefix:fooMode"/>
where fooprefix is bound to a unique namespace-uri
Often the author of a stylesheet that will be imported doesn't know
what stylesheets will be importing it. The only sound protection from
a template with higher imort precedence being selected instead of owr
own is to provide it with unique mode.
In FXSL there is a general convention that referenced templates (whose
template references are passed as parameters to other
templates/functions) must have:
mode="f:FXSL"
where "f" is bound to "http://www.sf.net/fxsl"
The templates that are passed such parameters initiate the referenced
templates using:
<xsl:apply-templates mode="f:FXSL"/>
Of course, this is incompatible with the idea of xsl:apply-imports
and, it turns out, the idea of xsl:apply-imports is not a bulletproof
one.
See for example: "Reliance on import precedence considered dangerous "
by Jeni Tennison at:
http://www.xslt.com/html/xsl-list/2001-02/msg00613.html
Hope this helped.
Cheers,
Dimitre Novatchev.
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] How to use multiple xsl:i, Pieter Reint Siegers | Thread | RE: [xsl] How to use multiple xsl:i, Pieter Reint Siegers |
| [xsl] creating nodes from text, omprakash . v | Date | RE: [xsl] help with java.lang.outof, Michael Kay |
| Month |