- From: Kay, Michael <Michael.Kay@softwareag.com>
- Date: Sun, 25 Jan 2004 22:45:56 +0100
- To: <public-qt-comments@w3.org>, <mike@skew.org>
The original comment {qt-2003Dec0117-01}: http://lists.w3.org/Archives/Public/public-qt-comments/2003Dec/0117.html came from Mike Brown. This is the official response from the XSL Working Group. The WG considered that no change was needed to the language specification, but asked the editor to consider adding a clarifying note or example. In response to the questions: 1. XSLT 2.0 says that fn:id() is supposed to work on a temporary tree [2]. I do not see how any unique IDs that this function needs are going to be found in the temporary tree. It's not possible for one to associate a DTD or other schema with a temporary tree in order to force ID-ness or other type information onto the attribute nodes in it, correct? So I would expect that fn:id() would never return any nodes, when the context item is a node from the temporary tree, since there are no unique IDs in the temporary tree. If I'm correct, here, I propose that you add a note about this to XSLT 2.0. Response: if you validate an element or attribute in a temporary tree, by using the validation or type attributes on a relevant XSLT instruction, and if as a result of validation the node acquires a type annotation of xs:ID, then the fn:id() function when applied to that temporary tree has the ability to locate this node. At its simplest, you can do: <xsl:variable name="temp"> <a> <xsl:attribute name="id" type="xs:ID" select="ABC"/> </a> <b> <xsl:attribute name="id" type="xs:ID" select="XYZ"/> </b> </xsl:variable> and then the call $temp/id('ABC') will find element <a>. I propose to add an example along these lines to XSLT section 19.2.1. 2. I'm actually having trouble finding where in the XPath 2.0 specs there is any discussion of the mechanism of assignment of unique IDs (as would be used by fn:id()) to nodes. Appendix B of the function spec says "The recognition of a node as an id value is sensitive to the manner in which the datamodel is constructed", but the data model spec says only that "[Node identity] should not be confused with the concept of a unique ID, which is a unique name assigned to an element by the author to represent references using ID/IDREF correlation"; nothing else, AFAIK. Did I miss something? Response: The description of the fn:id() function in Functions and operators states: The result of the function is a sequence, in document order, of those elements that are in the same document as the context node, and that have an ID value equal to one or more of the IDREFs in the list of candidate IDREFs. An element has an ID value of V if it has an attribute whose type is xs:ID and whose value is V, or if the element itself is of (simple) type xs:ID and has a value of V. The phrase "an attribute whose type is xs:ID" means that the attribute must have a type annotation that is xs:ID or a type derived by restriction from xs:ID. As explained in XSLT section 19.2.1, an attribute node acquires such a type annotation as a result of validation. Could you confirm that you are happy with this explanation? Thank you for raising the comment. Michael Kay
Received on Sunday, 25 January 2004 16:46:32 UTC