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

Re: Ignoring ambiguous matches

Subject: Re: Ignoring ambiguous matches
From: Graydon <graydon@xxxxxxxxx>
Date: Wed, 12 Feb 2014 20:35:25 -0500
Re:  Ignoring ambiguous matches
On Thu, Feb 13, 2014 at 01:06:25AM +0000, Ihe Onwuka scripsit:
> I am about to write several template rules that will all match the
> same node but will each apply (or try to apply) a different edit.
> 
> I don't care the order in which these are applied as long as each gets
> a shot at applying it's edit.
> 
> I was wondering whether I can just ignore the ambiguous match warnings
> and be confident that everything is A - ok or whether I have to
> diligently invent template priorities to prevent that.

If you need everything to match, it's not safe to ignore ambiguous rule
match warnings; you're going to get only one of the rules matching,
hopefully the last one.

For XSLT 2.0, last thing in section 6.4 of the spec:

"It is a recoverable dynamic error if the conflict resolution algorithm
for template rules leaves more than one matching template rule. The
optional recovery action is to select, from the matching template rules
that are left, the one that occurs last in declaration order."

Why not find the node and do everything you need to do to that node
inside that template.

Usually something like

<xsl:variable name="pass1">
    <xsl:apply-templates mode="pass1" select="."/>
</xsl:variable>

<xsl:variable name="pass2">
    <xsl:apply-templates mode="pass2" select="$pass1"/>
</xsl:variable>

and eventually

<xsl:sequence select="$passn"/>

Whatever transform you want at each step has to be present as templates
with the appropriate modes.

Next match for multiple templates is tricky, you have to be sure all the
templates have exactly the same priority or set the priorities carefully
and this, well, there's a reason one generally prefers to let the
processor deal with priority.

-- Graydon

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.