RE: XML Schema Datatype Questions

I'm just a spectator here, but here is my shot at answering your questions.

> --- Daniel Potter <dpotter@mitre.org> wrote:

> > If I specify that mininclusive=0 and
> > maxinclusive=INF, then is NAN in
 > that range?

From
http://java.sun.com/docs/books/vmspec/2nd-edition/html/Concepts.doc.html#334
99

NaN is unordered, so the numerical comparison operators <, <=, >, and >=
return false if either or both operands are NaN. The equality operator ==
returns false if either operand is NaN, and the inequality operator !=
returns true if either operand is NaN. In particular, x != x is true if and
only if x is NaN, and (x<y) == !(x>=y) will be false if x or y is NaN.


    boolean ok = (0 >= x && x <= Double.infinity)

would return false.  My interpretation is that NaN will always be invalid if
there is any kind of bound facet.

What about mininclusive=-3 and
> > maxexclusive=4?  Or does NAN
> > need to be specified in the enumeration?  (On that
> > note, can the
> > enumeration facet be used to allow values outside
> > the range specified by
> > min/max to be included?  Or do enumeration values
> > need to fall within
> > the range?

With the exception of the enumeration facet, all the other facets appear to
form one big AND.  I'd say the logical formulation is all of the
non-enumeration facets must be true and one of the enumeration facets must
be true and you must acceptible to the base type.  (This distinct treatment
of enumeration is undesirable in my eye.  I'd like something closer to the
previous form or my earlier suggestion
http://lists.w3.org/Archives/Public/www-xml-schema-comments/1999OctDec/0022.
html where the entire enumeration is one facet and the specific literals are
child elements of it.  I'm planning on updating that suggestion for the new
draft.).

For example,

<datatype name="oblivion" source="double">
    <minInclusive value="3"/>
    <maxInclusive value="4"/>
    <enumeration value="NAN"/>
</datatype>

should have an empty lexical space.  Only NaN passes the enumeration test
and it is not in the range specified.  Your scenario requires some sort of
"or" facet and "and" facet.

<datatype source="double">
    <or>
        <and>
            <minInclusive value="3"/>
            <maxInclusive value="4"/>
       </and>
        <enumeration value="NAN"/>
    </or>
</datatype>

Note: If we were to do that, then add a <not> element to.  That would make
it simple to disallow a previous enumeration value: such as

<datatype name="Mon-Thurs" source="Mon-Friday">
    <not>
        <enumeration value="Friday"/>
    </not>
</datatype>

There is no constraint saying that
> > enumeration and min/max
> > values cannot be set together, which leads me to
> > believe that they are
> > combined to describe legal values.)

With the previous interpretation, you should be able to have any combination
of facets but they are interpreted as a big AND.  With that explicit
interpretation, we don't have any ambiguity is someone specifies both a
minInclusive and a minExclusive and don't have to try to figure which one to
keep, we can just evaluation both and they both better be true.  Just like
Java or C++ would allow you to do

    if(x > 3 && x >= 4)

The behavior is defined, though the duplicate specification comes at slight
performance penalty.

> > Also relating to float, are the characters case
> > sensitive?  Can I use
> > "inf" as a value or does it need to be "INF"?  Is
> > "6.22e22" legal?  Or
> > does it need to be "6.22E22"?

Formulation [34] would indicate that both 6.22e22 and 6.22E22 are legal.
Formulations [31] and [32] would indicate that the only legal representation
of infinity is INF and of not an number is NaN (which is inconsistent with
section 3.2.4.1 which states NAN)

It is curious that these representations were used since the are different
than those used in XSLT and Java (section 12.3 of XSLT and
http://web2.java.sun.com/docs/books/jls/html/javalang.doc9.html#5899) which
would use +Infinity, -Infinity and NaN.

> > One last question:  For the binary datatype, what is
> > the default
> > encoding?  According to the encoding facet, it must
> > be either hex or
> > base64, but what happens if the user doesn't
> > specify?  If I specify that
> > an element is of type binary, but leave out the
> > encoding facet, what
> > encoding is then used?  As far as I can tell, there
> > is no default value
> > for encoding.  I would assume hex is default because
> > it is listed first,
> > but it would be nice to know for certain which
> > encoding is truely
> > intended as default.
> >

Someone should put a default in or make the encoding a required attribute.

Now for my question, what is the appropriate way to disallow NaN from a
datatype without constraining the dataspace.  I'd try the following, but
maybe should be an explicit solution (or if this one is okay it should be
added in the draft or some errata)

<datatype name="noNaN" source="double">
    <minInclusive value="-INF"/>
</datatype>

Received on Thursday, 6 January 2000 01:46:55 UTC