"Christian" == Christian Rinderknecht
<rinderkn(_at_)konkuk(_dot_)ac(_dot_)kr> writes:
Christian> <xsl:for-each-group select="cities/city"
Christian> group-by="@country"> <xsl:value-of select="position()/>
Christian> </xsl:for-each-group>
Christian> which prints the positions of each group as determined
Christian> by the document order of the first item of each group,
Christian> and
This returns the context position, which is defined as:
"the context position is the position of this item within the set of
initial items (that is, one item for each group in the population) in
population order, "
so effectively it is the position of the group within the sequence of
groups.
Christian> <xsl:for-each-group select="cities/city"
Christian> group-by="@country"> <xsl:value-of
Christian> select="./position()/> </xsl:for-each-group>
Christian> which prints the position of the first item in each
Christian> group, i.e., 1.
The context item (.) is defined as "the context item is the initial item
of the group". This is a sequence of 1 item. So ./position() is giving
the context position within a sequence of 1 item, so it will always be 1.
Christian> But
Christian> <xsl:value-of select="@country"/>
Christian> and
Christian> <xsl:value-of select="./@country"/>
Christian> return the same value.
Yes. Because you are asking for the country attribute:
a) of the first item in each group, and
b) of each item in a sequence of one (the first item in the group)
Christian> Does this mean that, in general, an XPath expression
Christian> "p" is NOT equivalent to "./p"? (Philip Wadler (2001),
The / operator changes the context item, so yes.
Christian> in his paper entitled "A formal semantics of patterns
Christian> in XSLT" at
Christian>
http://homepages.inf.ed.ac.uk/wadler/topics/xml.html#xsl-semantics
Christian> wrote, about his formalisation of a fragment of XPath
Christian> 1.0 that `It follows immediately that the patterns
Christian> p/. and p and ./p are all equivalent.')
Expressions are not patterns - the latter are syntactically a subset
of the former, but the semantics of pattern matching are not those of
expression evaluation.
Christian> Moreover, you say that "position()" (i.e., the context
Christian> position) is not a property of a node, but the XPath
Christian> 2.0 standard says that "It changes whenever the context
Christian> item changes." The only related standard where I found
Christian> the word "iteration" is in 14.1 of the XSLT 2.0
Christian> Standard, about the notion of "Current Group". In
Christian> particular, it is not found in XPath nor the Data
Christian> Model, so I am not sure what you mean, since position()
Christian> can be used as
Christian> <xsl:value-of select="cities/city/position()"/>
Christian> where I do not see any iteration (in a loopish sense).
That is correct. of course, the implementation may well involve a
loop, but it does not have to.
Christian> Also, the constructor sequence in the
Christian> xsl:for-each-group element could be evaluated in
Christian> concurrent threads having a different context item,
Or concurrent processes. Or for that matter a sequential evaluation in
a different order from that of the sequence, results being
subsequently re-ordered to preserve the semantics.
Christian> that is, there is no sequentiality implied when
Christian> evaluating the sequence
Correct. That is, there is a sequential ordering of results that must
be observed, but no temporal evaluation order.
Christian> and the iteration you refer to
Christian> seems to me more a concept related to the serialisation
Christian> of the output (the side effect of the evaluation). (The
Serialization does not necessarily take place.
--
Colin Adams
Preston Lancashire
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--