On 17 Jan 2014, at 18:14, Ihe Onwuka <[email protected]> wrote:

> Continuing on the them of recreating the limitations of the physical world.
> 
> <xsl:apply-templates select="someNode"/>
> 
> where someNode does not exist in the document has no effect.
> 
> <xsl:apply-templates select="doc('somedoc'/someNode)
> 
> where somedoc doesn't exist .....error - failed to load document.
> 
> But really it's just another non-existent node.
> 

At the time the doc() function was introduced to XPath 2.0, there was several 
years' experience of the document() function, which had different error 
behaviour. The problems with this were well known and the design of the 
function pair doc-available() and doc() was designed to overcome these problems.

One difference between reading an external document and selecting a node is 
that reading an external document can fail for a great variety of reasons of 
which the absence of the document is only one. (It might exist but have 
incorrect permissions, or be ill-formed, or be schema-invalid, or the network 
might be down). In general if you can't read it you want to know why. Ttreating 
all these conditions in the same way would give no opportunity for error 
information. If you want to treat absence of the document as a non-error 
condition, doc-available enables you to do that (you can trivially write your 
own function that combines doc-available() and doc() to achieve the wanted 
effect).

So I would defend the current design.

But I would also question what you are trying to achieve by raising the 
question. When you use a programming language or function library, you can 
always find aspects of its design that could be improved, either for your 
particular use case or for the world at large. But 99% of the time you can 
achieve what you want, so what's the point of complaining? You know full well 
that the design isn't going to be improved in a subsequent release unless 
there's an issue that's a real stopper, because people expect backwards 
compatibility. It's like whinging about (say) the fact that XML doesn't treat 
form-feed as whitespace: there are bigger fish to fry, move on. If you feel you 
can do a better design job than this, then get involved, rather than shouting 
from the sidelines: there are plenty of standards activities that are short of 
contributors.

Michael Kay
Saxonica



_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk

Reply via email to