[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

XQuery treatment of xs:positiveInteger?

David Sewell dsewell at virginia.edu
Tue Jul 20 10:42:17 PDT 2004


xs positiveinteger
Thanks to Peter, Till, and Michael for the explanation! So a fix to that
sample code would entail (at least)

  my:simple-add( 2 cast as xs:positiveInteger, 3 cast as xs:positiveInteger)

Cumbersome, but at least I understand now what would be required to use
a derived integer data type in a function to constrain input values.
Looks like it's easier to use xs:integer with an explicit check on
values instead.

David

> Michael Kay
>
> > -----Original Message-----
> > From: http://xquery.com/mailman/listinfo/talk
> > [mailto:http://xquery.com/mailman/listinfo/talk] On Behalf Of David Sewell
> > Sent: 20 July 2004 04:31
> > To: http://xquery.com/mailman/listinfo/talk
> > Subject:  XQuery treatment of xs:positiveInteger?
> >
> > Given the following XQuery code:
> >
> >   declare namespace my = "uri:foo";
> >
> >   declare function my:simple-add($x as xs:positiveInteger,
> >                                  $y as xs:positiveInteger) as
> > xs:positiveInteger
> >       { $x + $y };
> >
> >   my:simple-add(2, 3)
> >
> > Shouldn't this happily produce '5' for output, as it would if the data
> > types were all xs:integer?
> >
> > I get complaints about argument type when I run this on three
> > different
> > XQuery processors. For example, Saxon 8:
> >
> > "Required type of first argument of my:simple-add()
> >   is xs:positiveInteger; supplied value has type xs:integer"
> >
> > How can '2' not be interpreted as xs:positiveInteger?  (Adding a "+"
> > before the arguments doesn't make a difference.)
> >
> > Am I missing something totally obvious about use of derived
> > data types,
> > or is this a parser bug?
> >
> > David
> >
> > --
> > David Sewell, Editorial and Technical Manager
> > Electronic Imprint, The University of Virginia Press
> > PO Box 400318, Charlottesville, VA 22904-4318 USA
> > Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
> > Email: http://xquery.com/mailman/listinfo/talk   Tel: +1 434 924 9973
> >
> > _______________________________________________
> > http://xquery.com/mailman/listinfo/talk
> > http://xquery.com/mailman/listinfo/talk
> >
>
>

-- 
David Sewell, Editorial and Technical Manager
Electronic Imprint, The University of Virginia Press
PO Box 400318, Charlottesville, VA 22904-4318 USA
Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
Email: http://xquery.com/mailman/listinfo/talk   Tel: +1 434 924 9973
Web: http://www.ei.virginia.edu/


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