[
Lists Home |
Date Index |
Thread Index
]
On rereading this I see a bunch of errors in my XQuery and a lack of clarity in my question. Let's try again
According to Jonathan Robie type promotion on function arguments isn't polymorphic for built-in numeric types so
define function is-integer(xs:decimal $d) returns xs:boolean{
$d instance of xs:integer
}
is-integer(xs:integer(10))
returns false. Thus built-in numeric types when promoted lose any information about their position in the type hierarchy since it is essentially a copy that of the value as a new type that is passed to the function. So I have a few questions
Q1: What happens with user numeric defined types? If I define a myns:shoesize type and then write
import schema namespace myns="http://www.example.com" at "http://www.example.com/myns.xsd"
define function is-shoesize(xs:decimal $d) returns xs:boolean{
$d instance of myns:shoesize
}
is-shoesize(cast as myns:shoesize(10))
does this return false? If so this may be problematic for users. If not, then it seems inconsistent.
Q2: Are arguments to functions promoted by value for all built-in types in the W3C XML Schema type hierarchy or just for numerics? Does the following return true or false?
define function is-NCName(xs:string $s) returns xs:boolean{
$s instance of xs:NCName
}
is-NCName(xs:NCName("ncname"))
Q3: How about user defined custom types? Are they polymorphic or not? Again does this return true or false?
import schema "ipo.xsd"
declare namespace ipo="http://www.example.com/IPO"
define function is-USAddress(ipo:Address $a){
$s instance of element of type ipo:USAddress
}
is-USAddress( validate{
<billTo xsi:type="ipo:USAddress">
<name>Robert Smith</name>
<street>8 Oak Avenue</street>
<city>Old Town</city>
<state>PA</state>
<zip>95819</zip>
</billTo>
})
-----Original Message-----
From: Dare Obasanjo
Sent: Fri 8/16/2002 1:59 PM
To: Jonathan Robie; Simon St.Laurent
Cc: xml-dev@lists.xml.org
Subject: RE: [xml-dev] RE: XQuery subset (was RE: [xml-dev] WXS acronym?)
> -----Original Message-----
> From: Jonathan Robie
> [mailto:jonathan.robie@datadirect-technologies.com]
> Sent: Friday, August 16, 2002 1:54 PM
> To: Dare Obasanjo; Simon St.Laurent
> Cc: xml-dev@lists.xml.org
> Subject: RE: [xml-dev] RE: XQuery subset (was RE: [xml-dev]
> WXS acronym?)
>
> >It also has interesting type issues like what happens when I do this
> >
> >function is-integer(xs:decimal $d) returns xs:boolean{
> > $d instance of xs:integer
> >}
> >
> > is-integer(xs:integer(6661))
> >
> >Does the query return true or false? Both answers have unpleasant
> >ramifications.
>
> The function conversion rules say that the integer is converted to a
> decimal, so it returns false.
So function parameters are not polymorphic for numeric types? So if I
have a simpletype called myns:shoesize then
function is-integer(xs:decimal $d) returns xs:boolean{
$d instance of xs:shoesize
}
is-integer(myns:shoesize(11))
returns false? I'd love to explain that to our users.
So are other types treated polymorphically (e.g. string types, complex
types) or do function conversion rules only discriminate against the
numeric types?
--
PITHY WORDS OF WISDOM
Blessed are the meek for they shall inherit the Earth, minus 40%
inheritance tax.
This posting is provided "AS IS" with no warranties, and confers no
rights.
-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>
The list archives are at http://lists.xml.org/archives/xml-dev/
To subscribe or unsubscribe from this list use the subscription
manager: <http://lists.xml.org/ob/adm.pl>
|