OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] XQuery and DTD/Schema?

[ Lists Home | Date Index | Thread Index ]

Jonathan Robie wrote:

> 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

Wrong.  This function assumes that <price> has some numeric type and can 
meaningfully be summed.  The type has presumably been identified to the 
xquery engine using XSchema vocabulary, presumably as xs:decimal.  The 
presumption that a schema validation operation has actually taken place 
is without evidence - in a large proportion of cases the data has 
probably been generated programmatically and flowed straight into a 
database, no angle-brackets in evidence anywhere.

I'm really feeling uneasy - a lot of people whom I consider to be smart 
seem to be participating consensually in the belief that data types are 
organically tied to the validation process, which to me seems 
empirically just nutty.

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

It depends; if the data being queried is actually XML, when you 
encounter the string of characters that ostensibly represent <price> 
you're going to have to convert them to a number to do arithmetic, and 
if you don't have exception handling logic surrounding this process 
you're just being lazy and stupid - so it's not clear that you ever 
escape the process of "validation".  If on the other hand this is 
actually something that is known to be an integer and thus stored in a C 
or Java "int", you couldn't test it against a schema anyhow because it's 
no longer XML.  So arguments claiming that static typing is good because 
  it bypasses runtime validation are basically without merit.

Having said that, I'm not in Uche's "static typing is evil" camp :)

And named types do seem awfully convenient, so I'm really not 
disagreeing with Jonathan's main point at all. -Tim





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS