<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>20634</bug_id>
          
          <creation_ts>2013-01-10 14:17:21 +0000</creation_ts>
          <short_desc>[XP 3.0] The XSD 1.1 type xs:error</short_desc>
          <delta_ts>2013-03-19 15:54:44 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XPath 3.0</component>
          <version>Last Call drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Kay">mike</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>g</cc>
    
    <cc>tim</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>81185</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-01-10 14:17:21 +0000</bug_when>
    <thetext>XSD 1.1 introduces a new type called xs:error. We need to say something about it.

xs:error a type with an empty value space. As such, we will never encounter instances of it at run time, either as atomic values or as type-annotated nodes. But as things stand, it&apos;s defined to be present in every schema, and as such it can be used in expressions like

$x treat as xs:error

The definition of xs:error is as a union type with no member types. It therefore falls into our definition of a &quot;pure union type&quot; and therefore a &quot;generalized atomic type&quot;. There is therefore a constructor function xs:error($in) (which always fails FORG0001, except when $in is the empty sequence), and we can use the type name in a SequenceType.

Generally the semantics seem to fall out quite naturally from the definition, and we don&apos;t need to say very much, but we should mention that it&apos;s allowed and have some test cases.

One thing that might need a little more care is the type:type subtyping rules. According to our rules, xs:error will be a subtype of every union type. I think that in XSD xs:error is also substitutable for every atomic type, but I&apos;m having trouble seeing where it says this.

An alternative approach would be to say that the type xs:error is NOT available for use in queries. This is an unnecessary and artificial restriction, but it might save implementors a bit of work, it would require fewer tests, and few users would grieve over it. But even if this is what we say, we still need to say something.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81186</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-01-10 14:24:02 +0000</bug_when>
    <thetext>On reflection, I don&apos;t think that prohibiting xs:error would save any work for implementors, because the behaviour is exactly the same as a user-defined union type with no member types, and implementations need to support that anyway.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81952</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2013-01-22 17:32:59 +0000</bug_when>
    <thetext>XQuery Formal Semantics 1.0 describes the &apos;none&apos; type as:

&quot;... none is ... equivalent to a union type with no member types.&quot;

Perhaps xs:error is the same type as, or at least very closely related to, &apos;none&apos;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81954</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-01-22 17:54:51 +0000</bug_when>
    <thetext>Some further observations:

(a) we say in 4.11: [Definition: A schema import imports the element declarations, attribute declarations, and type definitions from a schema into the in-scope schema definitions. For each user-defined generalized atomic type in the schema, schema import also adds a corresponding constructor function. ]. 

So it seems that at least in the case where there is an &quot;import schema&quot; declaration, we already import the type xs:error (because it is present in every schema), and we also add a corresponding constructor function xs:error() whose behaviour is rather similar to fn:error(). 

If there is no &quot;import schema&quot; declaration, the status quo is less clear.

(b) since xs:error is an empty union, and since a user-defined XSD 1.1 schema can include an empty union type, there are no new semantic problems - there is no doubt that a query can import an empty union type and that its semantics must be well-defined, the only question is whether it imports the particular empty union type called xs:error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82522</commentid>
    <comment_count>4</comment_count>
    <who name="Ghislain Fourny">g</who>
    <bug_when>2013-02-04 14:20:17 +0000</bug_when>
    <thetext>Here is a concrete proposal against the spec which officially allows xs:error (only substantive changes are shown - notes can also be added at various places in the specification to clarify some aspects).

XDM 3.0
=======
2.7.2 Predefined Types
- Add xs:error to the list of additional types and to the list of types superseded by XML Schema 1.1.
- &quot;five additional types&quot; -&gt; make it six

- Add the following paragraph:
xs:error
The datatype xs:error is a union type with no member types. Its base type is xs:anySimpleType. It cannot exist as a dynamic type as its value space and lexical space are empty.

XQuery 3.0
==========

2.5.1 Predefined Schema Types

- Add to the list summarizing schema types specified in the XDM:
[Definition: xs:error is a simple type with no value space. It can be used in the SequenceType syntax to raise errors.]


Add paragraph 2.5.7 xs:error

The type xs:error has an empty value space and it never appears as a dynamic type or as the content type of a dynamic element or attribute type. It offers an alternative way of raising errors, in addition to fn:error.

Cast to xs:error raises an error or returns the empty sequence.
Promotion to xs:error is not possible.
xs:error (as well as xs:error+) does not match any value, is a subtype of all simple types, and a supertype only of itself.
xs:error? and xs:error* are identical to empty-sequence().
A variable binding with a type declaration xs:error always raises a type error.
Calling a function in the signature of which xs:error appears always raises a type error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84624</commentid>
    <comment_count>5</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2013-03-19 15:54:44 +0000</bug_when>
    <thetext>In today&apos;s telcon, the Working Group accepted comment #4 as the resolution of this bug.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>