|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Top N Most Common Mistakes [SEC=UNCLASSIFIED]Michael Kay mike at saxonica.comWed Aug 15 02:25:07 PDT 2007
> > By this, Michael, do you mean anything more than "use named > types rather than anonymous types" in your Schemas? If so, > can you elaborate on what "properly" means here? To get compile time checking of your query against a schema, you need to declare the types of variables and of arguments to functions. You also need to ensure that the expected type of the context item and of the result of doc() is known statically. This is best done by defining global variables, for example declare variable $in as document-node(schema-element(purchase-order)) := (/); declare variable $books as document-node(schema-element(booklist)) := := doc('books.xml'); declare function f:orders-for-customer($c as schema-element(customer)) as schema-element(order)* { ... } When you write a path expression and the type of the first step in the path is known, Saxon-SA will give you warnings if any subsequent steps are incapable of selecting any nodes. Using named types in your schemas is useful because it allows you to refer to them in your queries - but there's no benefit unless you actually do refer to them! Michael Kay http://www.saxonica.com/
|
Purchase Stylus Studio Online Today!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

![Top N Most Common Mistakes [SEC=UNCLASSIFIED]](/images/get_stylus.gif)




