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

Re: XQuery and DTD/Schema?


invoice.dtd
> Let me try to explain why I think named typing is good. Here's a function:
> 
> define function get-total( element invoice $i )
>    returns xs:decimal
> {
>          sum( $i//item/price )
> }
> 
> This function assumes that the invoices it takes have been validated as 
> invoice elements according to some schema, and are not merely well-formed 
> elements whose name happens to be 'invoice'. At run-time, you don't want to 
> have to test every function parameter to see if it corresponds to a schema, 
> you simply want to ensure that the validator has said this corresponds to 
> the appropriate definition.

You keep saying this sort of thing, and it baffles me.  Its a solution in 
search of a problem if I ever saw one.  If the substrate data is *XML* (this 
is what we're here to discuss, right?) then why do these declaration have to be

a) static
b) based on a named type system
c) a and/or b only as provided within a schema

a) There is no reason it has to be static.  The semantics of sum can be 
"accept or convert to an integer".  This is how XPath 1.0 does things.  And 
I'll make the technical point that you know very well Simon has made enough 
times: this is the way to do it that is more cleanly layered for XML 
processing.  I know you'll respond "but that's inefficient".  This is an 
*implementation* matter, and not a matter that should impose itself in the 
formal semantics.  There are many possible strategies for dynamic 
optimization.  And if these do not prove sufficient, static constraints can be 
*added on*.  You can extend the original dynamic system with a static axiom 
that all occurences of "$i//item/price" must be integers upon parsing.  Hell, 
Schematron can manage that with a REGEX extension function, never mind WXS.  
If you start with static typing as the sole vision, you pretty much cripple 
dynamic constriants.  They have no standing in the formal model, so how do I 
express my dynamic constraints in an XQuery function definition?

b) There is no reason it has to be named types.  The constraints that are used 
to improve the design or implementation of the function, whether static or 
dynamic can be "ad-hoc", declared in some constraint language (REGEXen are one 
example, RELAX NG is another) and made to be first-class constructs in the 
language, i.e. they can themselves be passed to functions and such.

c) Even if one were to say "XQuery requires static, named types" (I personally 
could readily accept named constraints, but static types are beyond the pale 
of evil to me) then the question remains, why do these *have* to be provided 
in a schema?  Why not divorce XQuery's typing semantics from the underlying 
parsing and pre-query processing?  Why not just say "the XQuery implementation 
must provide so and so static type information and so and so type inferencing 
functions" and leave it at that?  Why mandate that these come from the PSVI?


-- 
Uche Ogbuji                           Fourthought, Inc.
uche.ogbuji@f...           http://fourthought.com
http://4Suite.org                     http://uche.ogbuji.net
Track chair, XML/Web Services One (San Jose, Boston): 
http://www.xmlconference.com/
RDF Query using Versa - http://www-106.ibm.com/developerworks/xml/library/x-thi
nk10/index.html
WSDL and the Wild, Wild West - http://adtmag.com/article.asp?id=6004
XML, The Model Driven Architecture, and RDF @ XML Europe - 
http://www.xmleurope.com/2002/kttrack.asp#themodel



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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.