<?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>29868</bug_id>
          
          <creation_ts>2016-09-23 18:16:52 +0000</creation_ts>
          <short_desc>XQueryX stylesheet does not always convert arrowExpr to XQuery correctly</short_desc>
          <delta_ts>2016-10-07 10:56:09 +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>XQueryX 3.1</component>
          <version>Candidate Recommendation</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="Josh Spiegel">josh.spiegel</reporter>
          <assigned_to name="Josh Spiegel">josh.spiegel</assigned_to>
          <cc>andrew_coleman</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>127520</commentid>
    <comment_count>0</comment_count>
    <who name="Josh Spiegel">josh.spiegel</who>
    <bug_when>2016-09-23 18:16:52 +0000</bug_when>
    <thetext>The XQueryX for test ArrowPostfix-021 is:

&lt;xqx:module xmlns:xqx=&quot;http://www.w3.org/2005/XQueryX&quot;
            xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
            xsi:schemaLocation=&quot;http://www.w3.org/2005/XQueryX
                                http://www.w3.org/2005/XQueryX/xqueryx.xsd&quot;&gt;
  &lt;xqx:mainModule&gt;
    &lt;xqx:queryBody&gt;
      &lt;xqx:arrowExpr&gt;
        &lt;xqx:argExpr&gt;
          &lt;xqx:integerConstantExpr&gt;
            &lt;xqx:value&gt;2&lt;/xqx:value&gt;
          &lt;/xqx:integerConstantExpr&gt;
        &lt;/xqx:argExpr&gt;
        &lt;xqx:mapConstructor&gt;
          &lt;xqx:mapConstructorEntry&gt;
            &lt;xqx:mapKeyExpr&gt;
              &lt;xqx:integerConstantExpr&gt;
                &lt;xqx:value&gt;1&lt;/xqx:value&gt;
              &lt;/xqx:integerConstantExpr&gt;
            &lt;/xqx:mapKeyExpr&gt;
            &lt;xqx:mapValueExpr&gt;
              &lt;xqx:integerConstantExpr&gt;
                &lt;xqx:value&gt;2&lt;/xqx:value&gt;
              &lt;/xqx:integerConstantExpr&gt;
            &lt;/xqx:mapValueExpr&gt;
          &lt;/xqx:mapConstructorEntry&gt;
          &lt;xqx:mapConstructorEntry&gt;
            &lt;xqx:mapKeyExpr&gt;
              &lt;xqx:integerConstantExpr&gt;
                &lt;xqx:value&gt;2&lt;/xqx:value&gt;
              &lt;/xqx:integerConstantExpr&gt;
            &lt;/xqx:mapKeyExpr&gt;
            &lt;xqx:mapValueExpr&gt;
              &lt;xqx:integerConstantExpr&gt;
                &lt;xqx:value&gt;4&lt;/xqx:value&gt;
              &lt;/xqx:integerConstantExpr&gt;
            &lt;/xqx:mapValueExpr&gt;
          &lt;/xqx:mapConstructorEntry&gt;
          &lt;xqx:mapConstructorEntry&gt;
            &lt;xqx:mapKeyExpr&gt;
              &lt;xqx:integerConstantExpr&gt;
                &lt;xqx:value&gt;3&lt;/xqx:value&gt;
              &lt;/xqx:integerConstantExpr&gt;
            &lt;/xqx:mapKeyExpr&gt;
            &lt;xqx:mapValueExpr&gt;
              &lt;xqx:integerConstantExpr&gt;
                &lt;xqx:value&gt;6&lt;/xqx:value&gt;
              &lt;/xqx:integerConstantExpr&gt;
            &lt;/xqx:mapValueExpr&gt;
          &lt;/xqx:mapConstructorEntry&gt;
        &lt;/xqx:mapConstructor&gt;
        &lt;xqx:arguments&gt;
        &lt;/xqx:arguments&gt;
      &lt;/xqx:arrowExpr&gt;
    &lt;/xqx:queryBody&gt;
  &lt;/xqx:mainModule&gt;
&lt;/xqx:module&gt;

The XQueryX to XQuery stylesheet produces the following:

( 2 =&gt; map { 1 : 2 , 2 : 4 , 3 : 6 } () )

This is not a valid XQuery because the map constructor needs to be in a parenthesized expression.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127521</commentid>
    <comment_count>1</comment_count>
    <who name="Josh Spiegel">josh.spiegel</who>
    <bug_when>2016-09-23 19:10:35 +0000</bug_when>
    <thetext>I propose conditionally adding parens around &lt;xsl:apply-templates select=&quot;.&quot;/&gt;

  &lt;xsl:template match=&quot;xqx:arrowExpr&quot;&gt;
    &lt;xsl:value-of select=&quot;$LPAREN&quot;/&gt;
    &lt;xsl:value-of select=&quot;$SPACE&quot;/&gt;
    &lt;xsl:apply-templates select=&quot;xqx:argExpr&quot;/&gt;
    &lt;xsl:for-each select=&quot;*[not(self::xqx:argExpr) and not(self::xqx:arguments)]&quot;&gt;
      &lt;xsl:text&gt; =&amp;gt; &lt;/xsl:text&gt;
      &lt;xsl:choose&gt;
        &lt;xsl:when test=&quot;self::xqx:EQName or self::xqx:variableRef&quot;&gt;
          &lt;xsl:apply-templates select=&quot;.&quot;/&gt;
        &lt;/xsl:when&gt;
        &lt;xsl:otherwise&gt;
          &lt;xsl:value-of select=&quot;$LPAREN&quot;/&gt;
          &lt;xsl:apply-templates select=&quot;.&quot;/&gt;
          &lt;xsl:value-of select=&quot;$RPAREN&quot;/&gt;
	&lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
      &lt;xsl:choose&gt;
        &lt;xsl:when test=&quot;following-sibling::*[1][self::xqx:arguments]&quot;&gt;
          &lt;xsl:for-each select=&quot;following-sibling::*[1][self::xqx:arguments]&quot;&gt;
            &lt;xsl:call-template name=&quot;parenthesizedList&quot;/&gt;
          &lt;/xsl:for-each&gt;
	&lt;/xsl:when&gt;
        &lt;xsl:otherwise&gt;
          &lt;xsl:value-of select=&quot;$LPAREN&quot;/&gt;
          &lt;xsl:value-of select=&quot;$RPAREN&quot;/&gt;
        &lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
    &lt;/xsl:for-each&gt;
    &lt;xsl:value-of select=&quot;$SPACE&quot;/&gt;
    &lt;xsl:value-of select=&quot;$RPAREN&quot;/&gt;
  &lt;/xsl:template&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127688</commentid>
    <comment_count>2</comment_count>
    <who name="Andrew Coleman">andrew_coleman</who>
    <bug_when>2016-10-07 10:56:09 +0000</bug_when>
    <thetext>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.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>