Saxon 9.7.0.5 Template Priorities.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Saxon 9.7.0.5 Template Priorities.

Ihe Onwuka-2
I have a stylesheet with one template

<xsl:template match="*[somePredicate]">
    dostuff
</xsl:template>

This works fine. Of course the built in templates output the data in all elements that don't match this template so to suppress that I added.

<xsl:template match="*"/>

I now get no output, which means that it is overriding the template with the predicate, which is contrary to the default template priority rules.

I also get no output even when I explicitly put priorities on both templates and give  a higher priority given to the predicated template. 

Has there been a known regression with template priorities?









------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Saxon 9.7.0.5 Template Priorities.

John Lumley-2
Unless your topmost element matches your predicate, the nullifying rule fires as it's the only one that matches and does exactly what you asked - outputs nothing.


> On 19 Aug 2016, at 17:18, Ihe Onwuka <[hidden email]> wrote:
>
> I have a stylesheet with one template
>
> <xsl:template match="*[somePredicate]">
>     dostuff
> </xsl:template>
>
> This works fine. Of course the built in templates output the data in all elements that don't match this template so to suppress that I added.
>
> <xsl:template match="*"/>
>
> I now get no output, which means that it is overriding the template with the predicate, which is contrary to the default template priority rules.
>
> I also get no output even when I explicitly put priorities on both templates and give  a higher priority given to the predicated template.
>
> Has there been a known regression with template priorities?
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help



------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Saxon 9.7.0.5 Template Priorities.

Michael Kay
In reply to this post by Ihe Onwuka-2

> On 19 Aug 2016, at 17:18, Ihe Onwuka <[hidden email]> wrote:
>
> I have a stylesheet with one template
>
> <xsl:template match="*[somePredicate]">
>     dostuff
> </xsl:template>
>
> This works fine. Of course the built in templates output the data in all elements that don't match this template so to suppress that I added.
>
> <xsl:template match="*"/>
>
> I now get no output, which means that it is overriding the template with the predicate,

No, you've made a wrong inference there.

If you have an element A that contains an element B, and B matches the predicate, then the rule will no longer fire, because when A is matched, your empty template rule matches A and doesn't process its children. So B is never selected for processing, so the predicate is never tested.

Michael Kay
Saxonica

------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Saxon 9.7.0.5 Template Priorities.

Ihe Onwuka-2
Ah hah..... and that is exactly what is happening. 

Thanks.

On Fri, Aug 19, 2016 at 1:33 PM, Michael Kay <[hidden email]> wrote:

> On 19 Aug 2016, at 17:18, Ihe Onwuka <[hidden email]> wrote:
>
> I have a stylesheet with one template
>
> <xsl:template match="*[somePredicate]">
>     dostuff
> </xsl:template>
>
> This works fine. Of course the built in templates output the data in all elements that don't match this template so to suppress that I added.
>
> <xsl:template match="*"/>
>
> I now get no output, which means that it is overriding the template with the predicate,

No, you've made a wrong inference there.

If you have an element A that contains an element B, and B matches the predicate, then the rule will no longer fire, because when A is matched, your empty template rule matches A and doesn't process its children. So B is never selected for processing, so the predicate is never tested.

Michael Kay
Saxonica


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help