At 2010-04-29 01:41 +0100, Fabre Lambeau wrote:
I have a complex XSLT stylesheet, which does import some other ones
in order to refine/delegate some of the work depending on the type
of data it finds.
This works by using templates with modes, and matching rules that
are more specific, hence increasing their default priority. However,
in the main sheet (the one that imports the others), there is a case
where I want to force the most generic template to be applied, after
which it can call the others.
Well, importance trumps priority. The lowest priority template in
the importing stylesheet is more important than the highest priority
template in the imported stylesheet. So if I understand you above,
that's what you get in XSLT.
However, no matter what I do with the priority attribute, my
processor seems to always select the template from the imported stylesheet.
That surprises me.
Having said that, I tried to create a simple example (below), and
there I get just the opposite effect: I can never get the imported
template to apply instead of the generic one, even though it is more selective
=== Main sheet ===
<xsl:template mode="process-record" match="feed" priority="-9">
=== Imported sheet ===
=== Document ===
With this example, no matter what value I give to the priority
attributes, I always get the following result:
Which is exactly what I would expect: the importing stylesheet is
adding the <helloworld> and the <xsl:next-match/> is then reapplying
the last-matched node as if the last matched template didn't exist
... and so the <specialone> is being added under <helloworld>.
The relative priorities are irrelevant. The importance trumps any
use of priority.
Any idea what I'm doing wrong?
I'm lost as to what you were wanting to do "right". You say:
there is a case where I want to force the most generic
template to be applied, after which it can call the others
Isn't that what you are doing above? The template in the importing
stylesheet is being applied and during that it "calls" the template
in the imported stylesheet.
What result *exactly* did you want for the source document above?
. . . . . . . . . . . Ken
XSLT/XQuery training: San Carlos, California 2010-04-26/30
Principles of XSLT for XQuery Writers: San Francisco,CA 2010-05-03
XSLT/XQuery/UBL/Code List training: Trondheim,Norway 2010-06-02/11
Vote for your XML training: http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
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>