[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 Rys mrys at microsoft.com
Tue Aug 14 19:05:08 PDT 2007


  Top N Most Common Mistakes [SEC=UNCLASSIFIED]
SQL Server 2005 similarly will check your XPath expression against an XML datatype's associated XML Schema collection.

E.g.,

Declare @x xml(MySchemaCollection);

SELECT @x.query('/a/b');

will raise a compile time error if none of the XML Schemas in the schema collection allow for a b element contained inside an a element.

Best regards
Michael

-----Original Message-----
From: http://x-query.com/mailman/listinfo/talk [mailto:http://x-query.com/mailman/listinfo/talk] On Behalf Of Michael Kay
Sent: Tuesday, August 14, 2007 5:25 PM
To: 'Smith, Donald T.'; http://x-query.com/mailman/listinfo/talk; http://x-query.com/mailman/listinfo/talk; http://x-query.com/mailman/listinfo/talk
Subject: RE:  Top N Most Common Mistakes [SEC=UNCLASSIFIED]

>
> 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/

_______________________________________________
http://x-query.com/mailman/listinfo/talk
http://x-query.com/mailman/listinfo/talk



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.