- From: <bugzilla@wiggum.w3.org>
- Date: Mon, 05 Jun 2006 22:49:24 +0000
- To: public-qt-comments@w3.org
- CC:
http://www.w3.org/Bugs/Public/show_bug.cgi?id=3315 Summary: [XqueryX] spurious "as" in typeswitch clause with no variable Product: XPath / XQuery / XSLT Version: Candidate Recommendation Platform: PC OS/Version: Windows XP Status: NEW Severity: normal Priority: P2 Component: XQueryX AssignedTo: jim.melton@acm.org ReportedBy: davidc@nag.co.uk QAContact: public-qt-comments@w3.org The Schema for typeswitch case clause is <xsd:element name="typeswitchExprCaseClause"> <xsd:complexType> <xsd:complexContent> <xsd:extension base="expr"> <xsd:sequence> <xsd:element ref="variableBinding" minOccurs="0"/> <xsd:element ref="typeDeclaration"/> <xsd:element name="resultExpr" type="exprWrapper"/> which means that there is always a "typeDeclaration" even if there is no variable binding. The XSLT though has <xsl:template match="xqx:typeswitchExprCaseClause"> <xsl:text> case </xsl:text> <xsl:apply-templates select="xqx:variableBinding"/> <xsl:apply-templates select="xqx:typeDeclaration"/> <xsl:text> return </xsl:text> <xsl:apply-templates select="xqx:resultExpr"/> </xsl:template> and <xsl:template match="xqx:typeDeclaration"> <xsl:text> as </xsl:text> <xsl:apply-templates select="*"/> </xsl:template> so typeDeclaration always gets processed and the text " as " is always generated. so an XQuery Clause of case xs:integer return -1 if converted to XQueryX and back comes out as case as xs:integer return -1 which is a syntax error. I think the correct fix is to change the schema to use sequenceType rather than typeDeclaration as the child of typeswitchExprCaseClause as that brings XQueryX back closer to the XQuery EBNF [44] CaseClause ::= "case" ("$" VarName "as")? SequenceType "return" ExprSingle An alternative (but not so nice, I think) would be to leave the schema as-is but add another template to the stylesheet matching match="xqx:typeswitchExprCaseClause/xqx:typeDeclaration" that does not put in the "as" if there is no variable binding child. (the stylesheet will need some changes in either case to make sure tahtas is inserted if there is a variable binding and a type.). A third possibility that wouldn't require a change to the stylesheet would be to make the schema allow a variable binding _or_ a sequence type but not both. (the variable binding clause does itself allow a child sequence type). It turns out that the XQuery Test suite (even in 0.9) had no tests for case clauses that do not bind a variable so this has gone undetected for quite a while. Some additional tests by Frans Englich picked this up. David
Received on Monday, 5 June 2006 22:49:40 UTC