xsl-list
[Top] [All Lists]

Re: How to use multiple xsl:import

2005-04-06 04:19:13
On Apr 6, 2005 9:50 AM, Pieter Reint Siegers Kort
<pieter(_dot_)siegers(_at_)elnorte(_dot_)com> 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.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>