This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29868 - XQueryX stylesheet does not always convert arrowExpr to XQuery correctly
Summary: XQueryX stylesheet does not always convert arrowExpr to XQuery correctly
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQueryX 3.1 (show other bugs)
Version: Candidate Recommendation
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Josh Spiegel
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-23 18:16 UTC by Josh Spiegel
Modified: 2016-10-07 10:56 UTC (History)
1 user (show)

See Also:


Attachments

Description Josh Spiegel 2016-09-23 18:16:52 UTC
The XQueryX for test ArrowPostfix-021 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:arrowExpr>
        <xqx:argExpr>
          <xqx:integerConstantExpr>
            <xqx:value>2</xqx:value>
          </xqx:integerConstantExpr>
        </xqx:argExpr>
        <xqx:mapConstructor>
          <xqx:mapConstructorEntry>
            <xqx:mapKeyExpr>
              <xqx:integerConstantExpr>
                <xqx:value>1</xqx:value>
              </xqx:integerConstantExpr>
            </xqx:mapKeyExpr>
            <xqx:mapValueExpr>
              <xqx:integerConstantExpr>
                <xqx:value>2</xqx:value>
              </xqx:integerConstantExpr>
            </xqx:mapValueExpr>
          </xqx:mapConstructorEntry>
          <xqx:mapConstructorEntry>
            <xqx:mapKeyExpr>
              <xqx:integerConstantExpr>
                <xqx:value>2</xqx:value>
              </xqx:integerConstantExpr>
            </xqx:mapKeyExpr>
            <xqx:mapValueExpr>
              <xqx:integerConstantExpr>
                <xqx:value>4</xqx:value>
              </xqx:integerConstantExpr>
            </xqx:mapValueExpr>
          </xqx:mapConstructorEntry>
          <xqx:mapConstructorEntry>
            <xqx:mapKeyExpr>
              <xqx:integerConstantExpr>
                <xqx:value>3</xqx:value>
              </xqx:integerConstantExpr>
            </xqx:mapKeyExpr>
            <xqx:mapValueExpr>
              <xqx:integerConstantExpr>
                <xqx:value>6</xqx:value>
              </xqx:integerConstantExpr>
            </xqx:mapValueExpr>
          </xqx:mapConstructorEntry>
        </xqx:mapConstructor>
        <xqx:arguments>
        </xqx:arguments>
      </xqx:arrowExpr>
    </xqx:queryBody>
  </xqx:mainModule>
</xqx:module>

The XQueryX to XQuery stylesheet produces the following:

( 2 => map { 1 : 2 , 2 : 4 , 3 : 6 } () )

This is not a valid XQuery because the map constructor needs to be in a parenthesized expression.
Comment 1 Josh Spiegel 2016-09-23 19:10:35 UTC
I propose conditionally adding parens around <xsl:apply-templates select="."/>

  <xsl:template match="xqx:arrowExpr">
    <xsl:value-of select="$LPAREN"/>
    <xsl:value-of select="$SPACE"/>
    <xsl:apply-templates select="xqx:argExpr"/>
    <xsl:for-each select="*[not(self::xqx:argExpr) and not(self::xqx:arguments)]">
      <xsl:text> =&gt; </xsl:text>
      <xsl:choose>
        <xsl:when test="self::xqx:EQName or self::xqx:variableRef">
          <xsl:apply-templates select="."/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$LPAREN"/>
          <xsl:apply-templates select="."/>
          <xsl:value-of select="$RPAREN"/>
	</xsl:otherwise>
      </xsl:choose>
      <xsl:choose>
        <xsl:when test="following-sibling::*[1][self::xqx:arguments]">
          <xsl:for-each select="following-sibling::*[1][self::xqx:arguments]">
            <xsl:call-template name="parenthesizedList"/>
          </xsl:for-each>
	</xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$LPAREN"/>
          <xsl:value-of select="$RPAREN"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
    <xsl:value-of select="$SPACE"/>
    <xsl:value-of select="$RPAREN"/>
  </xsl:template>
Comment 2 Andrew Coleman 2016-10-07 10:56:09 UTC
At the meeting on 2016-10-04, the WG agreed to adopt the proposal in comment #1

Action A-656-05 was raised to track this.