Yes, but in fact in this case, extra quotes doesn't change anything to this behavior. I can't reproduce this test case on previous ML versions (currently on 6.0-1.1). Seem's to be introduce with the latest version and I guess It could leads to errors.
Stéphane Le 22 janv. 2013 à 18:07, Michael Blakeley <[email protected]> a écrit : > That looks like normal, if confusing, behavior to me. XPath defines > position() as a dynamic context function, so its meaning can change during > evaluation. > > http://www.w3.org/TR/xpath20/#id-xp-evaluation-context-components > > http://www.w3.org/TR/xpath20/#dt-dynamic-context > > I think this is the most relevant bit: > >> The context position is the position of the context item within the sequence >> of items currently being processed.] It changes whenever the context item >> changes. When the focus is defined, the value of the context position is an >> integer greater than zero. The context position is returned by the >> expression fn:position(). When an expression E1/E2 or E1[E2] is evaluated, >> the context position in the inner focus for an evaluation of E2 is the >> position of the context item in the sequence obtained by evaluating E1. The >> position of the first item in a sequence is always 1 (one). The context >> position is always less than or equal to the context size. > > > After [exists(*)] has been evaluated, [1] sees every document-node() in > collection('test')[*] as its own input sequence. Therefore every document has > position() = 1. So the behavior is confusing, but correct. > > What you probably want is: > > (collection(test)[*])[1] > > The extra parens change the scope of the [1] predicate. > > -- Mike > > On 22 Jan 2013, at 08:44 , Stéphane TOUSSAINT > <[email protected]> wrote: > >> Hi, >> >> I just found something wrong (I guess) with XPath predicates on ML 6.0-2.1 >> >> The following query returns weird result : >> >> fn:count(for $doc in fn:collection("test")[fn:exists(*)][1] >> return $doc) >> >> Say I put 10 documents in collection "test", I guess this query return only >> 1 (the first document) document from the collection. But instead it returns >> 10 documents. >> I seems that after the first predicates there is 10 sequences of 1 document >> each instead of one single collection with 10 document inside. >> >> For information, this is the minimal test case I was able to write, but it >> is the same with more complexe predicates. >> >> Note that >> >> for $doc in fn:collection("test")[1] >> return $doc >> >> successfully return one single element. >> >> Any clue? thanks >> >> Stéphane >> _______________________________________________ >> General mailing list >> [email protected] >> http://developer.marklogic.com/mailman/listinfo/general > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
