[Bug 4924] [XQX] Arguably incorrect element definition in XQueryX's Schema

http://www.w3.org/Bugs/Public/show_bug.cgi?id=4924

           Summary: [XQX] Arguably incorrect element definition in XQueryX's
                    Schema
           Product: XPath / XQuery / XSLT
           Version: Recommendation
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XQueryX
        AssignedTo: jim.melton@acm.org
        ReportedBy: jim.melton@acm.org
         QAContact: public-qt-comments@w3.org


In the XQueryX Recommendation (http://www.w3.org/TR/xqueryx), the XML Schema
defined at http://www.w3.org/TR/xqueryx/#Schema has an important design error. 
While the schema as published correctly defines unenhanced XQueryX
representations of XQuery semantics, several element definitions are done in
such a manner that makes the schema not extensible to comprehend, say, the
Update Facility and Full-Text. 

The element definitions in question are those whose definitions have an
anonymous complex type.  The solution is to re-define them by creating a named
complex type that is "the same as" each such anonymous complex type, and then
defining each such element as a reference to the new complex type. 

For the purposes of defining the XQueryX extensions for the Update Facility,
only one such element proved to be problematic: 

  <xsd:element name="functionDecl" substitutionGroup="prologPartTwoItem">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="functionName" type="QName"/>
        <xsd:element ref="paramList"/>
        <xsd:element ref="typeDeclaration" minOccurs="0"/>
        <xsd:choice>
          <xsd:element name="functionBody" type="exprWrapper"/>
          <xsd:element name="externalDefinition" type="emptyContent"/>
        </xsd:choice>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

The solution is pretty straightforward:

  <xsd:complexType name="functionDeclType">
      <xsd:sequence>
        <xsd:element name="functionName" type="QName"/>
        <xsd:element ref="paramList"/>
        <xsd:element ref="typeDeclaration" minOccurs="0"/>
        <xsd:choice>
          <xsd:element name="functionBody" type="exprWrapper"/>
          <xsd:element name="externalDefinition" type="emptyContent"/>
        </xsd:choice>
      </xsd:sequence>
  </xsd:complexType>

  <xsd:element name="functionDecl" type="functionDeclType"
               substitutionGroup="prologPartTwoItem"/>

This allows the Update Facility to refine the functionDecl element by adding a
new attribute to represent, for a given function being declared, whether or not
that function is an updatable function:

  <xsd:element name="ufFunctionDecl" substitutionGroup="xqx:prologPartTwoItem">
    <xsd:complexType>
      <xsd:complexContent>
        <xsd:extension base="xqx:functionDeclType">
          <xsd:attribute name="updatingFunction" type="xsd:boolean"/>
        </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
  </xsd:element>

The changes to the XQueryX Recommendation's XML Schema should be made as
quickly as possible in the form of an erratum.

Received on Thursday, 9 August 2007 00:07:46 UTC