Thanks for taking the time to look at this so quickly. I'm still unsure how #2 isn't a sequence if #3 is.
Anyhow, if it all works as intended, I'm fine with using a variable or () to make sure the returned nodes are cast into a sequence.
I'm just a bit surprised that text nodes and element nodes are returned differently.
Regards,
France
On Wed, Mar 2, 2016 at 3:43 PM, Christian Grün christian.gruen@gmail.com wrote:
And a little addition:
$node//text()[1]
…is an abbreviation for…
$node/descendant-or-self::node()/child::text()[1]
However, you are probably looking for:
$node/descendant::text()[1]
It’s completely fine to use parentheseses, as in this case, your query will exactly be rewritten as shown above.
On Wed, Mar 2, 2016 at 8:28 PM, Jens Erat jens.erat@uni-konstanz.de wrote:
This is a matter of precedence.
<li>{ $node//text()[1] }</li>
Has the meaning of "return all text nodes, that are in first position of their encapsulating element". Consider the intermediate result after partial evaluation to be something like
("allo!"[1], "Il pleut des clous."[1])
Applying parenthesis as you proposed in #4 resolves the issue:
<li>{ ($node//text())[1] }</li>
resulting in
("allo!", "Il pleut des clous.")[1]
instead.
This is not an issue in $5, as all text nodes are stored in a sequence (which is flattened), and you return the first result of the flattened sequence.
-- Jens Erat Universität Konstanz Kommunikations-, Infomations-, Medienzentrum (KIM) Abteilung Basisdienste D-78457 Konstanz Mail: jens.erat@uni-konstanz.de