ASP Error: 70
Description: Permission denied
Source: Microsoft VBScript runtime error

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

RE: Do Templates Conflict?

Subject: RE: Do Templates Conflict?
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Thu, 5 May 2005 09:26:17 +0100
msxml xsl bug ignores xsl
> 1. The one with highest "import precedence" is selected
>     (Import precedence is determined by your import hierarchy
> when you use
>      xsl:import to bring in stylesheet modules, enabling you
> to override
>      imported templates transparently in an importing
> stylesheet. If you
>      want modularity without this behavior, use xsl:include.)

There is a massive gotcha here (or a bug in the spec, depending on your
point of view).

Consider a stylesheet that imports two stylesheets, which both contain a
template that matches the same element:

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:import href="a.xsl"/>
<xsl:import href="b.xsl"/>

<xsl:template match="/">
	<xsl:apply-imports/>
</xsl:template>
</xsl:stylesheet>


'a.xsl':


<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="node" priority="10">A</xsl:template>

</xsl:stylesheet>


'b.xsl':


<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="node">B</xsl:template>

</xsl:stylesheet>


Note the template in 'a.xsl' specifies priority 10.  Even with this, the
output is 'B' from 'b.xsl'.  Because the first rule in template conflict
resolution is import precedence, and one of the rules of import
precedence is 'the last import wins', so the processor ignores all the
usual ways to control priority.


> One reason many of us like Saxon for development is that
> Saxon will signal
> a warning before it uses the last best template. MSXML simply
> uses that
> one. Other processors signal an error. YMMV.

However in this case, the usual "ambiguous rule match" warning isn't
output, making it very hard to track down.  I have asked Mike on the
Saxon list a while back if it's possible to give a warning for this
specific case, so hopefully it will make it into 8.5 :)  (From memory I
think it wasn't possible for the priority attribute to work across the
'built' stylesheet, so a warning is next-best).

cheers
andrew

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.