This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
This is along a similar vein to #4273 and #3818, but has some added issues with the typing of fn:root hence I am reporting as a separate bug We are using the expression "//@status = 'failed'" where the context is an untyped document "document (element (*,xs:unTyped))" This fails to type check as @status is found to be anyAtomicType. The reason this happens is "//" is normalized to "fn:root(self::node()) treat as document-node)/descendant-or-self::node()/" As mentioned in #3818 the treat as document-node throw away typing information (namely that the document is untyped) so all data in return nodes will be xs:anyType. With our suggested static typing extensions in comment #16 we run into the problem that fn:root returns node()? which is not a subtype of document-node (which is presumably why the treat as expression was used in the first place). Therefore for the "//" expression to be able to work in a static type checking environment with untyped documents I think there need to be explicit static typing rules for fn:root which return the appropriate type rather than by use of treat as in the path expression.
I can't comment very intelligently on static typing issues, but just one observation: the reason for the "treat as document-node()" in the expansion of "/" is to ensure that "/" is an error when the context item is a node in a tree whose root is not a document node. In such a tree, root() will select an element node (say), but "/" throws an error. Michael Kay
This is a known problem with the semantics of path expressions starting with '/' and '//'. The main problem here is the use of the fn:root() function which goes up the document, and for which we cannot easily do static typing. I think the way static typine works here is not really a bug on XQuery 1.0, but possibly may be a request for XQuery 1.1 feature. - Jerome
Nick, The working groups have reviewed your comment. This issue has been considered in the past, and the group feels that we cannot provide better static typing for '/' and '//' right now because of the use of the fn:root() function. We will consider this as a possible improvement for the next version. Best regards, - Jerome Simeon, On behalf of the XSLT and XML Query working groups