[
Lists Home |
Date Index |
Thread Index
]
At 12:47 PM 5/7/2002 -0400, Elliotte Rusty Harold wrote:
>At 9:28 AM -0700 5/7/02, Jonathan Robie wrote:
>
>>>Because an XML document is defined as a finite sequences of characters.
>>
>>Actually, XML Schema defines value spaces for the various types, and many
>>people are doing XML views of persistent data.
>
>But the schema is most definitely *not* a fundamental part of the XML
>document. What the schema says is in the document does not change what is
>in the document. What is in the document are strings, not numbers, not
>dates, but strings. You may choose to apply a certain schema to the
>document and use the information in that schema to inform the processing
>choices you make; but that in no way implies that I or anyone else has to
>apply the same schema, or indeed any schema at all. You may call
><foo>45.67</foo> a float. I may call it a BigDecimal or a Money or an
>Address, but all it really is is a string. Each of us would have to
>instantiate the relevant type we want from the string we actually have.
And until we create a system that does have types, we can't begin to use
the information and have it behave the way we want it to.
But XQuery works directly on the XML, and does not require you to suck it
up into some typed system. I don't know how to average your foo or sort it
until you tell me its type.
As it happens, one way of giving an untyped value a datatype in XQuery is
to use it in an arithmetic expression - this casts untyped data to double.
If the cast fails, the query fails, but you have know way of knowing for
sure whether you will encounter this error at runtime. It's safer to use a
schema that guarantees that a foo has a numeric type, and a query system
that can look at the schema and the query and tell you in advance that your
average function will only be called for numeric data.
But with XQuery, it's up to you. We support either approach.
What behavior would you like XQuery and XPath to adopt that is different
from what is in the current Working Drafts? Can you illustrate the
advantages of this behavior with an example?
Jonathan
|