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 2528 - [xqueryx] check for node tests in xsl
Summary: [xqueryx] check for node tests in xsl
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQueryX 1.0 (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Jim Melton
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-16 00:09 UTC by David Carlisle
Modified: 2006-01-12 10:04 UTC (History)
0 users

See Also:


Attachments

Description David Carlisle 2005-11-16 00:09:11 UTC
<xsl:template match="xqx:functionCallExpr">
    <xsl:if test="xqx:functionName/@xqx:prefix">
      <xsl:value-of select="xqx:functionName/@xqx:prefix"/>
      <xsl:value-of select="$COLON"/>
    </xsl:if>
    <xsl:if test="xqx:functionName = 'node' or
                  xqx:functionName = 'document-node' or
                  xqx:functionName = 'element' or
                  xqx:functionName = 'attribute' or
                  xqx:functionName = 'schema-element' or
                  xqx:functionName = 'schema-attribute' or
                  xqx:functionName = 'processing-instruction' or
                  xqx:functionName = 'comment' or
                  xqx:functionName = 'text' or
                  xqx:functionName = 'item' or
                  xqx:functionName = 'if' or
                  xqx:functionName = 'typeswitch' or
                  xqx:functionName = 'empty-sequence'">
      <xsl:text>fn:error()</xsl:text>
    </xsl:if>
    <xsl:value-of select="xqx:functionName"/>


The check on 'node' and friends needs to be moved into a branch that only
happens if there is no xqx:prefix. Currently the stylesheet rejects the xqx
version of the valid, executable XQuery


declare namespace x = "x";
declare function x:text () {()};
x:text()
`

as it rejects any function with local name "text".

The result of the stylesheet in this case also reveals a couple more problems


declare namespace x="x";
 declare function x:text()
{
()
};
x:fn:error()text()

The resulting Query does not include a call to fn:error() as intended as this is
mixed up with the function call that is being flagged as an error,and the result
is that the Query does not parse, which is a kind of error, but I don't think it
was as intended. It would be easy to arrange the template so that in the branch
that generates error() the original function nameand arguments were dropped
completely, although this would then still fail if fn: namespace has been
redeclared. It would be safer to generate the error message during the
transformation with an xsl:message terminate="yes" rather than trying to cause
the generated query to always raise an error.



and for completeness the xqueryx version of the Xquery test shown above:

<xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX">
   <xqx:mainModule>
      <xqx:prolog>
         <xqx:namespaceDecl>
            <xqx:prefix>x</xqx:prefix>
            <xqx:uri>x</xqx:uri>
         </xqx:namespaceDecl>
         <xqx:functionDecl>
            <xqx:functionName xqx:prefix="x">text</xqx:functionName>
            <xqx:paramList/>
            <xqx:functionBody>
               <xqx:sequenceExpr/>
            </xqx:functionBody>
         </xqx:functionDecl>
      </xqx:prolog>
      <xqx:queryBody>
         <xqx:functionCallExpr>
            <xqx:functionName xqx:prefix="x">text</xqx:functionName>
            <xqx:arguments/>
         </xqx:functionCallExpr>
      </xqx:queryBody>
   </xqx:mainModule>
</xqx:module>
Comment 1 Jim Melton 2005-12-25 00:47:51 UTC
Two very nice catches, indeed!

I will propose to the Working Groups that I be directed to modify the template
for xqx:functionCallExpr in the ways you suggested.  The proposal will be that
the template look something like this:

  <xsl:template match="xqx:functionCallExpr">
    <xsl:choose>
      <xsl:when test="xqx:functionName/@xqx:prefix">
        <xsl:value-of select="xqx:functionName/@xqx:prefix"/>
        <xsl:value-of select="$COLON"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test="xqx:functionName = 'node' or
                      xqx:functionName = 'document-node' or
                      xqx:functionName = 'element' or
                      xqx:functionName = 'attribute' or
                      xqx:functionName = 'schema-element' or
                      xqx:functionName = 'schema-attribute' or
                      xqx:functionName = 'processing-instruction' or
                      xqx:functionName = 'comment' or
                      xqx:functionName = 'text' or
                      xqx:functionName = 'item' or
                      xqx:functionName = 'if' or
                      xqx:functionName = 'typeswitch' or
                      xqx:functionName = 'empty-sequence'">
          <xsl:variable name="message"><xsl:text>Incorrect XQueryX: function
calls must not use unqualified "reserved" name "</xsl:text><xsl:value-of
select="xqx:functionName"/><xsl:text>"</xsl:text></xsl:variable>
          <xsl:message terminate="yes"><xsl:value-of
select="$message"/></xsl:message>
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:value-of select="xqx:functionName"/>
    <xsl:choose>
      <xsl:when test="xqx:arguments">
        <xsl:for-each select="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:template>

Your additional thoughts and comments on this proposed solution would be welcomed. 
Comment 2 Jim Melton 2006-01-11 17:55:00 UTC
The XML Query WG has considered your comment and the response suggested in
additional comment #1, and has agreed to adopt the solution proposed in that
response as the resolution of your comment. 

This is the official WG response. 

Please let us know if you agree with this resolution of your issue, by adding a
comment to the issue record and changing the Status of the issue to Closed. Or,
if you do not agree with this resolution, please add a comment explaining why.
If you wish to appeal the WG's decision to the Director, then also change the
Status of the record to Reopened. If you wish to record your dissent, but do not
wish to appeal the decision to the Director, then change the Status of the
record to Closed. If we do not hear from you in the next two weeks, we will
assume you agree with the WG decision.
Comment 3 David Carlisle 2006-01-12 10:04:32 UTC
looks fine to me, thanks