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

RE: matching elements by name and type to detect inval

Subject: RE: matching elements by name and type to detect invalid xpaths
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 6 Oct 2008 18:35:38 +0100
RE:  matching elements by name and type to detect inval
> Compile that with a schema-aware processor (Saxon SA in this 
> case) and you are told:
> 
> "The complex type root does not allow a child element named wrong;"
> 
> You don't even have to validate any input, because the match 
> pattern contains the type it knows that "wrong" is not a 
> child of <root>...
> fantastic :)
> 
> I think this means you can enjoy the benefits of the paths in 
> your XSLT being checked against the schema _without_ being 
> forced to validate the input each time... which is a huge benefit.
> 

Yes, it is a huge benefit, especially when you write stylesheets for complex
industry schemas that require path expressions a mile long. Three caveats:

(a) you only get this compile-time checking if you are careful to declare
your types, e.g. the types of variables and parameters, and to define match
patterns in terms of schema-element() or element(N,T).

(b) compile-time type checking is a feature of the processor, not of the
language. The other schema-aware processor doesn't do it...

(c) you DO still have to validate the input when you run the stylesheet,
because otherwise your pattern element(root, root) won't match the input.

Michael Kay
http://www.saxonica.com/

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.