[xquery-talk] xsi:type typing support

Howard Katz howardk at fatdog.com
Sat Mar 12 09:00:08 PST 2005


 > -----Original Message-----
 > From: Michael Kay [mailto:mhk at mhk.me.uk]
 > Sent: Saturday, March 12, 2005 6:49 AM
 > To: howardk at fatdog.com; talk at xquery.com
 > Subject: RE: [xquery-talk] xsi:type typing support
 >
 > I think it's quite hard to find a subset that's meaningful. The only
 > approach I can think of that might be workable is to restrict yourself to
 > simple types only.
 >
 > But I can't imagine why users would want to add
 > xsi:type="decimal" to every
 > <price> element in their source document, when it would be much easier to
 > cast the value of the element to a decimal in their queries.

In general I agree. However:

1) There's no need for the user to cast if the data's already typed,
2) In some cases if desirable xsi:type could easily be added
programmatically via XQuery or XSLT to existing source,
2) The documents might be machine-generated, with xsi:type info supplied by
the source process,
3) In both cases the addition of xsi:type info would provide
self-documentation, and
4) might be useful for making programmatic decisions for example as to
whether to do sorting or not, as in

let $results :=
	<results>
		<result><number xsi:type="xs:int">02</number></result>
		<result><number xsi:type="xs:int">1</number></result>
	</results>
return
	if ( count( $results//number[ @xsi:type="xs:int" ] )
		 eq count( $results//number ) )
	then
		for $num in $results//number
		order by xs:integer($num)
		return $num
	else
		for $num in $results//number
		return $num

Howard

 > Michael Kay
 > http://www.saxonica.com/
 >
 > > -----Original Message-----
 > > From: talk-bounces at xquery.com
 > > [mailto:talk-bounces at xquery.com] On Behalf Of Howard Katz
 > > Sent: 12 March 2005 01:13
 > > To: talk at xquery.com
 > > Subject: [xquery-talk] xsi:type typing support
 > >
 > > I'd like to be able to provide some very simple typing
 > > support with my query
 > > engine. I don't however want to tackle the whole PSVI thing
 > > (not having that
 > > many productive years ahead of me), but would be quite happy
 > > if I could do a
 > > "schema lite" version of my engine that just supported
 > > xsi:type. Is that
 > > doable without going the whole schema validation route? I
 > > keep thinking that
 > > what I need to know is right there in the spec, but every time I start
 > > digging into it, my eyes start rolling upward in my head and
 > > vertigo quickly
 > > ensues. Any pointers? Help my autumn years be productive
 > > ones, please! :-)
 > >
 > > Howard
 > >
 > >
 > > _______________________________________________
 > > talk at xquery.com
 > > http://xquery.com/mailman/listinfo/talk
 > >
 >
 >
 > _______________________________________________
 > talk at xquery.com
 > http://xquery.com/mailman/listinfo/talk
 >




More information about the talk mailing list