[Bug 27119] [XQX31] unnecessary nesting in array constructors

https://www.w3.org/Bugs/Public/show_bug.cgi?id=27119

--- Comment #4 from C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com> ---
I don't wish to re-open this issue, but in comment 2 Michael Dyck asks

    Can anyone give examples (aside from the constructs in question) 
    of how it's *not* "as light-weight as is consistent with clarity"? 

In connection with other work, I had occasion just now to ask the grammar
applet at [1] to generate an XQueryX translation of the expression "1 + 2".  

[1] http://www.w3.org/2013/01/qt-applets/xquery30/

The result is:

<xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.w3.org/2005/XQueryX
                                http://www.w3.org/2005/XQueryX/xqueryx.xsd">
  <xqx:mainModule>
    <xqx:queryBody>
      <xqx:addOp>
        <xqx:firstOperand>
          <xqx:integerConstantExpr>
            <xqx:value>1</xqx:value>
          </xqx:integerConstantExpr>
        </xqx:firstOperand>
        <xqx:secondOperand>
          <xqx:integerConstantExpr>
            <xqx:value>2</xqx:value>
          </xqx:integerConstantExpr>
        </xqx:secondOperand>
      </xqx:addOp>
    </xqx:queryBody>
  </xqx:mainModule>
</xqx:module>

The presence of so many single-child elements and the close alignment of
element names with non-terminals both seem to this observer to place the
XQueryX design much closer to the XML modeling of a concrete parse tree than to
the modeling of an abstract syntax tree "as light-weight as is consistent with
clarity".  Michael Dyck points out that there exceptions to the general rule of
turning each non-terminal in the concrete parse tree into an element; that does
seem to show that XQueryX is not quite as far towards the end of the spectrum
as I had thought.

But I believe MD exaggerates when he puts it closer to the other end of the
spectrum. 

One lighter-weight translation that seems to me consistent with clarity would
be:

<xqx:mainModule xmlns:xqx="http://www.w3.org/2005/XQueryX"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://www.w3.org/2005/XQueryX
                                   
http://www.w3.org/2005/XQueryX/xqueryx.xsd">
  <xqx:queryBody>
    <xqx:addOp>
      <xqx:integerConstantExpr>1</xqx:integerConstantExpr>
      <xqx:integerConstantExpr>2</xqx:integerConstantExpr>
    </xqx:addOp>
  </xqx:queryBody>
</xqx:mainModule>

This translation omits the elements module, firstOperand, secondOperand, and
value.  In general, a lighter-weight translation would result from
systematically deleting all nodes in the concrete parse tree which have only
single children, and the promotion of their children in their place.  A more
thoroughly ruthless application of this principle here would result in omitting
 queryBody and mainModule as well, so that the XML representation would be:

<xqx:addOp xmlns:xqx="http://www.w3.org/2005/XQueryX"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.w3.org/2005/XQueryX
                                http://www.w3.org/2005/XQueryX/xqueryx.xsd">
  <xqx:integerConstantExpr>1</xqx:integerConstantExpr>
  <xqx:integerConstantExpr>2</xqx:integerConstantExpr>
</xqx:addOp>

A designer seeking a lightweight XML representation in preference to close
modeling of the grammar might also prefer different element names:

<xqx:sum xmlns:xqx="http://www.w3.org/2005/XQueryX"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.w3.org/2005/XQueryX
                              http://www.w3.org/2005/XQueryX/xqueryx.xsd">
  <xqx:integer>1</xqx:integer>
  <xqx:integer>2</xqx:integer>
</xqx:sum>

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Saturday, 29 November 2014 01:31:10 UTC