Re: [xsl] [XSLT 1.0] Q: recursively eliminate empty nodes

Subject: Re: [xsl] [XSLT 1.0] Q: recursively eliminate empty nodes
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Sun, 14 Nov 2010 12:53:13 +0000
I just noticed (from here: http://www.w3.org/TR/xslt20/#dt-default-priority) that in XSLT 2.0, "/" has priority -0.5, whereas it has +0.5 in XSLT 1.0. I was surprised to see this. Maybe it has no practical impact (other than invalidating my easy-to-remember rule). Or am I missing something?


I'm trying to recall the reasoning. It was something like this: In XSLT 1.0, "/" (or a union with "/" as one of its branches) was the only pattern that could ever match a document (aka root) node. So its priority didn't really matter much, except perhaps in the artificial case where you have two templates saying match="/", one with an explicit priority and one without. In 2.0 it made sense to align its priority with other patterns where the node-kind and nothing else was known: it means the same as match="document-node()" which should logically have the same priority as "element()" or "attribute()" or "text()". Retaining the 1.0 priority would have meant match="/" having a higher priority than match="document-node(element(invoice))", which would be counter-intuitive.

Michael Kay
Saxonica

Current Thread