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 27707 - [XSLT3.0] Conflicting information about the permitted parents of xsl:context-item and whether or not xsl:mode can have children
Summary: [XSLT3.0] Conflicting information about the permitted parents of xsl:context-...
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Working drafts
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-26 23:38 UTC by dnovatchev
Modified: 2015-10-29 09:50 UTC (History)
1 user (show)

See Also:


Attachments

Description dnovatchev 2014-12-26 23:38:25 UTC
The 2nd Last Call of the XSLT 3.0 specification contains conflicting information about the possible parents of the <xsl:context-item> element. 
Section 10.1.1 “Declaring the Context Item for a Template”  (http://www.w3.org/TR/2014/WD-xslt-30-20141002/#element-context-item) contains this definition:

“The xsl:context-item element is used as a child of xsl:template, to declare the required type of the context item. It is intended particularly for use when the containing template is called using an xsl:call-template instruction, but it also constrains the context item if the same template is invoked using xsl:apply-templates, xsl:apply-imports, or xsl:next-match.
<xsl:context-item
  as? = sequence-type
  use? = "required" | "optional" | "prohibited" />
If the as attribute is present then its value must be an ItemTypeXP30. If the attribute is omitted this is equivalent to specifying as="item()".
A type error is signaled if the supplied context item does not match its required type. No attempt is made to convert the context item to the required type (using the function conversion rules or otherwise). The error code is the same as for xsl:param: [see ERR XTTE0590].
If an xsl:context-item element is present as the first child element of xsl:template, it defines whether the template requires a context item to be supplied, and if so, what the type of the context item must be. If this template is the initial named template, then this has the effect of placing constraints on the global context item for the transformation as a whole.”

The quoted text above defines that an xsl:context-item is a child of xsl:template. Also implied (but not explicitly stated!) is that xsl:context-item (if present) must be the first child of the “xsl:template.

The information about xsl:template being the parent of xsl:context-item is additionally expressed in Appendix “D Element Syntax Summary (Non-Normative)”:
xsl:context-item

 	Model:
<xsl:context-item
  as? = sequence-type
  use? = "required" | "optional" | "prohibited" />
Permitted parent elements:
•	xsl:template


The problem is that in other parts of the document it is stated that xsl:contex-item can be a child of xsl:mode. For example, in section “6.6.1 Declaring Modes” it is said:

“For the unnamed mode, the effective value of each attribute is taken from an xsl:mode declaration that has no name attribute, and that specifies an explicit value for the required attribute. If there is no such declaration, the default value of the attribute is used. If there is more than one such declaration, the one with highest import precedence is used.
The above rules apply both to the attributes (other than name) of the xsl:mode element itself, and to the attributes of the contained xsl:context-item element if present.”

The provided syntax for the xsl:mode declaration in the same section defines it as having no content – thus no children element is permitted, including an xsl:context-item element.

And there is still another example, in section “2.9 Stylesheets and XML Schemas”, which shows explicitly an xsl:context-item element that is a child of an xsl:mode declaration:

“Example: Asserting the Required Type of the Source Document
<xsl:mode typed="lax">
  <xsl:context-item use="required"
                    as="document-node(schema-element(my:invoice))"/>
</xsl:mode>”

The set of this conflicting information makes questionable the definition of both: xsl:context-item (which are its permitted parents?) and xsl:mode (can it have content, or not).

I hope that this issue will be corrected in the next version of the XSLT 3.0 specification.
Dimitre Novatchev
Comment 1 Michael Kay 2015-01-07 23:02:56 UTC
The ability to have xsl:context-item as a child of xsl:mode was removed as part of the resolution of bug #24764. You have identified some residual text that should have been removed when implementing that decision, but which was not spotted. Thank you for pointing them out. Because the WG made a clear decision on this, I am treating the errors as editorial. Thank you for pointing them out. They will be fixed in the next version of the publication.
Comment 2 Michael Kay 2015-01-07 23:07:44 UTC
In fact, one of the two errors you point out has already been fixed as the resolution of bug #27152.