Menu

#983 Spurious type error when xsl:element name="" is not a string

v9.2
closed
5
2012-10-08
2009-09-15
Michael Kay
No

A spurious type error occurs when the name attribute of xsl:element is an attribute value such as name="{$var}" and the static type of $var is an atomic value other than a string: for example, if it is an xs:QName. The error message is "Required item type of @name attribute of xsl:element is xs:string; supplied value has item type xs:QName".

The underlying problem may well have other symptoms. The problem arises in the simplification of a SimpleContentConstructor, which is used to implement the rules for XSLT "Constructing simple content": that is, xsl:value-of, xsl:attribute, xsl:comment etc, as well as attribute value templates; and for the equivalent constructs in XQuery. If the value of the "select" expression in these instructions (or the constructed select expression in the case of an AVT) has a type that is singleton atomic, the optimizer replaces the SimpleContentConstructor with that select expression, neglecting to insert a conversion to type xs:string where this is needed. This normally does no harm, because the run-time code does a conversion to string anyway, but it causes a compile time problem if further analysis is done that relies on the value being a string.

A patch to the 9.2 branch (module net.sf.saxon.expr.SimpleContentConstructor) is being placed in Subversion.

Discussion

  • Michael Kay

    Michael Kay - 2009-09-15

    Minor correction: the patch is to module net.sf.saxon.instruct.SimpleContentConstructor.

     
  • Michael Kay

    Michael Kay - 2009-10-22

    Fixed in 9.2.0.3

     
  • Michael Kay

    Michael Kay - 2010-02-22

    Reopened: the bug is still present (at least for some test cases) in 9.2.0.6; and it also applies to xsl:attribute. Further patches have been committed to ComputedElement.java and ComputedAttribute.java, and new tests have been committed to the W3C test suite (element001-005, atrs61-65).

     
  • Michael Kay

    Michael Kay - 2010-08-09

    Fixed in 9.2.1.2 (probably earlier in fact)