[xquery-talk] xsi:type typing support

Michael Kay mhk at mhk.me.uk
Fri Mar 18 12:10:04 PST 2005


> I've been doing some reading over the weekend (XML Schema 
> Parts I and II and

> 
> (1) have the xsi: and xsd: namespaces declared formally in 
> the instance
> document, and
> (2) do the comparisons properly using fn:resolve-QName() and the like.

If you're going to test the value of an attribute that holds a QName, then
you need to do one of two things:

(a) declare the attribute in a schema as being of type QName (xsi:type is
implicitly thus declared) and validate the document against the schema

(b) convert the string value at run-time to an xs:QName by calling the
resolve-QName() function.

Doing a string comparison like @xsi:type="xs:decimal" is wrong; it will fail
if the user chose the prefix "xsd" instead of "xs".
> 
> I'm not sure what you mean by the last statement: "just so 
> that you don't
> have to do it for the content of the element". 

It's referring back to your original suggestion, of doing type-aware
operations on simple-valued elements that have an xsi:type attribute. I
think that if you do type-aware operations on elements but not on attributes
you get yourself into a mess.

Michael Kay




More information about the talk mailing list