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 2339 - fn:string-join problem
Summary: fn:string-join problem
Status: CLOSED WONTFIX
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 1.0 (show other bugs)
Version: Last Call drafts
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Ashok Malhotra
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-12 12:30 UTC by J
Modified: 2005-10-12 19:00 UTC (History)
0 users

See Also:


Attachments

Description J 2005-10-12 12:31:00 UTC
From my point of view, by (hopefully) cautiously reading the spec,
the last example given for string-join is just wrong:

fn:string-join(for $n in ancestor-or-self::* return name($n), '/')

shall return "/doc/chap/section"
and not      "doc/chap/section"

Why? I cannot see any reason why 
fn:string-join(('', 'a', 'b'), '+') shall return "a+b". It shall be "+a+b"!

If this is not a bug in the spec, it would be nice to put an example into
the spec and clarify the reason.





P.S.: the leading and trailing blank for the first two examples may confuse as 
well.
Comment 1 Michael Kay 2005-10-12 13:01:19 UTC
I believe the example is correct. I can't see why you think it is wrong. Perhaps
you read ancestor-or-self::* (which selects all element ancestors) as
ancestor-or-self::node() (which also selects the document node).

Michael Kay (personal response)
Comment 2 J 2005-10-12 15:03:34 UTC
Michael,
  you are correct! Its my fault, as in my special case (implementation)
we have no document node as the root node is just as normal as the others.
But nevertheless, it might be good idea to insert another example at
fn:string-join. Maybe

fn:string-join(('', 'a', 'b'), '+') return "+a+b"

thank you for your quick reaction
Comment 3 Michael Kay 2005-10-12 15:41:43 UTC
Whether or not your tree has a document node, ancestor::*/name() is going to
produce a sequence of non-empty names. It's only if your tree DOES have a
document node, and your XPath expression selects that node, that the sequence of
names will start with the string "", and the result of string-join will then
start with the delimiter "/".

Michael Kay