Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSL template priorities: Which comes first, priority or predicates?

Reply
Thread Tools

XSL template priorities: Which comes first, priority or predicates?

 
 
Soren Kuula
Guest
Posts: n/a
 
      04-13-2005
Hi,

Suppose I have:

<xsl:template match="foo[position()!=last()]"/>
<xsl:template match="foo[position()=last()]"/>

-- is that an error (same priority)? (my precessor reports nothing, buts
as far as I recall it doesn't really have to). Or is the priority a
post-predicate-survival issue?

Are these any better or worse (with respect to specification
fulfillment) that the above pair?

<xsl:template match="foo[position() &gt; 2]"/>
<xsl:template match="foo[position() &lt; 4]"/>

(yes I could find out for myself all right .. and who knows if I will be
the first onw ansering myself But isn't an interesting little gotcha?)

Soren

 
Reply With Quote
 
 
 
 
David Carlisle
Guest
Posts: n/a
 
      04-13-2005
Soren Kuula <dongfang-remove_this@remove_this-bitplanet.net> writes:

> Hi,
>
> Suppose I have:
>
> <xsl:template match="foo[position()!=last()]"/>
> <xsl:template match="foo[position()=last()]"/>
>
> -- is that an error (same priority)?


These two match patterns match distinct nodes so that is no more an
error than match="a" and match="b".

> (my precessor reports nothing, buts
> as far as I recall it doesn't really have to). Or is the priority a
> post-predicate-survival issue?
>
> Are these any better or worse (with respect to specification
> fulfillment) that the above pair?
>
> <xsl:template match="foo[position() &gt; 2]"/>
> <xsl:template match="foo[position() &lt; 4]"/>


here for position()=3 both templates match, with the same priority, so
this is an error, butit is specified as being recoverable with the
recovery action, if the processor does not report the error, is to take
the last one on the stylesheet. (This is the only case in which order of
the templates makes any difference.)

with saxon for example with -w0 no error is generated, with the default
-w1 a warning is made but the last template is used, with -w2 it is
taken as a fatal error.

> (yes I could find out for myself all right .. and who knows if I will be
> the first onw ansering myself But isn't an interesting little gotcha?)
>
> Soren


David
 
Reply With Quote
 
 
 
 
Malcolm Dew-Jones
Guest
Posts: n/a
 
      04-13-2005
Soren Kuula (dongfang-remove_this@remove_this-bitplanet.net) wrote:
: Hi,

: Suppose I have:

: <xsl:template match="foo[position()!=last()]"/>
: <xsl:template match="foo[position()=last()]"/>

: -- is that an error (same priority)? (my precessor reports nothing, buts
: as far as I recall it doesn't really have to). Or is the priority a
: post-predicate-survival issue?

xslt 1.0 sect 5.5

The processor _may_ signal an error if they both match and have the same
priority.

It doesn't have to signal an error, but in that case it _must_ choose the
match nearest the end of the style sheet (ie. the one that occurs last).

Is that what you mean by post-predicate-survival issue? If so then then
the answer is "yes".

In anycase, the only question is whether a processor will accept it at
all. Some obviously will, some might not, but if they do then the choice
of which template to use is unambiguous.

(I have nothing to say about your other question.)


--

This space not for rent.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
efficient priority queue for a few descrete priority levels Marcel Müller C++ 3 04-27-2009 03:22 PM
D300 BUG in Aperture Priority & Shutter Priority Mode Chico Digital Photography 21 06-23-2008 01:55 PM
Shutter Priority Vs. Aperture Priority Question mutefan@yahoo.com Digital Photography 13 09-14-2006 03:51 PM
Should I use shutter-priority or appurature-priority? ½ Confused Digital Photography 4 02-22-2006 09:48 AM
Question about Aperture priority and Shutter Priority John Edwards Digital Photography 8 01-05-2005 04:58 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57