Subject: Re: [xsl] Problem of template priority From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 28 Apr 2010 18:34:09 -0700 |
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.
However, no matter what I do with the priority attribute, my processor seems to always select the template from the imported stylesheet.
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:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="./special.xsl"/>
<xsl:template match="/"> <xsl:apply-templates mode="process-record"/> </xsl:template>
<xsl:template mode="process-record" match="feed" priority="-9"> <helloworld> <xsl:next-match/> </helloworld> </xsl:template> </xsl:stylesheet>
=== Imported sheet ===
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template mode="process-record" match="feed[@type='special']" priority="10">
<specialone/>
</xsl:template>
</xsl:stylesheet>
=== Document ===
<feed type="special"> <node/> </feed>
With this example, no matter what value I give to the priority attributes, I always get the following result:
<helloworld> <specialone/> </helloworld>
Any idea what I'm doing wrong?
there is a case where I want to force the most generic template to be applied, after which it can call the others
-- 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@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Problem of template prior, Imsieke, Gerrit, le- | Thread | RE: [xsl] Problem of template prior, Michael Kay |
Re: [xsl] Problem of template prior, Imsieke, Gerrit, le- | Date | Re: [xsl] How smart are the XSLT pr, Markus Flatscher |
Month |