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 10425 - [XSLT 2.1] snapshot() applied to attribute nodes
Summary: [XSLT 2.1] snapshot() applied to attribute nodes
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: 2010-08-25 08:22 UTC by Michael Kay
Modified: 2014-05-15 14:00 UTC (History)
0 users

See Also:


Attachments

Description Michael Kay 2010-08-25 08:22:53 UTC
The algorithm given in section 18.6 of the XSLT 2.1 WD to define the behaviour of the snapshot() function is incorrect in the case where the supplied node is an attribute or namespace node. The expression

<xsl:sequence select="$node/descendant-or-self::node()[$level]"/>

which terminates the recursion is assuming that the original node is a descendant of the root, which is not the case if it is an attribute or namespace.

The fix for this isn't easy, because when the original node is an attribute or namespace, all the attributes and namespaces of its parent element will be copied, so the only way we can find the right one is by name. 

One solution might be to build a path to the node and then evaluate that path using xsl:evaluate.
Comment 1 Michael Kay 2011-06-09 16:33:32 UTC
I have redesigned the algorithm for the snapshot() function and I believe the new code solves this problem. I'm therefore recording this as fixed.