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

Re: Avoiding boneheaded mistakes in XSLT?

Subject: Re: Avoiding boneheaded mistakes in XSLT?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 29 Dec 2010 23:36:35 +0000
Re:  Avoiding boneheaded mistakes in XSLT?
Even without schema awareness/context, surely the processor can
tell when an xpath expression will result in zero match?


No, it's very rarely possible.


For example, consider

<xsl:template match="books">
<xsl:value-of select="book[1]/authour"/>
</xsl:template>

Even if you have a schema telling you that the children of books can include book but the children of book can't include authour, this doesn't tell you that this path will necessarily return nothing - because there is no way you can know that every books element that the stylesheet processes will be valid against this schema.

In fact it's quite common for a stylesheet to create intermediate results that (deliberately) aren't valid against the schema for the input or output document.

It would however be possible to make a guess that this is wrong, and issue a warning. Incorrect warnings are always very irritating, so this is not something to be done lightly, but it's something I've wanted to attempt for a long time.

Michael Kay
Saxonica

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.