[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to use multiple xsl:import

Subject: Re: How to use multiple xsl:import
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Wed, 6 Apr 2005 21:19:13 +1000
owr templates
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.