Discussion:
[xquery-talk] Duke it out between you
Ihe Onwuka
2014-01-02 13:21:13 UTC
Permalink
<A name="me"><B><C score="" /><D>some content</D></B><B><C score="44"
/><D>some content</D></B></A>/
descendant::C[normalize-space(@score)]/
<g>{<x name="{ancestor::A/@name}" position="{position()}"/>,.}</g>

Now look what Saxon 9.3.0.5 gives for the position attribute

<g><x position="1" name="me"/><C score="44"/></g>

and eXist 3.0

<g>
<x name="me" position="0"/>
<C score="44"/>
</g>

The idea was to have returned the position of the instance of C that was
found within it's parent. I'm not convinced either are doing that but it's
a nice to have for me not a core so I will report and leave it at that.
Michael Sokolov
2014-01-02 13:54:52 UTC
Permalink
I think position()=0 is always (supposed to be) false()? Isn't it a
position in a 1-based sequence?

-Mike
Post by Ihe Onwuka
<A name="me"><B><C score="" /><D>some content</D></B><B><C score="44"
/><D>some content</D></B></A>/
Now look what Saxon 9.3.0.5 gives for the position attribute
<g><x position="1" name="me"/><C score="44"/></g>
and eXist 3.0
<g>
<x name="me" position="0"/>
<C score="44"/>
</g>
The idea was to have returned the position of the instance of C that
was found within it's parent. I'm not convinced either are doing that
but it's a nice to have for me not a core so I will report and leave
it at that.
w***@exist-db.org
2014-01-02 14:51:21 UTC
Permalink
Post by Ihe Onwuka
and eXist 3.0
<g>
<x name="me" position="0“/>
That’s most probably wrong and I strongly suspect it has the same cause as the other issue you reported before. I’ll look into it.

Wolfgang
Michael Kay
2014-01-02 17:21:29 UTC
Permalink
The idea was to have returned the position of the instance of C that was found within it's parent.
That's not what the position() function does. To get the position of a node $N among the children of its parent, use

count($N/preceding-sibling::node())+1

position() used on the rhs of "/" returns the position of the context item among the items selected; it will always be an ascending sequence starting at 1.

Michael Kay
Saxonica
<A name="me"><B><C score="" /><D>some content</D></B><B><C score="44" /><D>some content</D></B></A>/
Now look what Saxon 9.3.0.5 gives for the position attribute
<g><x position="1" name="me"/><C score="44"/></g>
and eXist 3.0
<g>
<x name="me" position="0"/>
<C score="44"/>
</g>
The idea was to have returned the position of the instance of C that was found within it's parent. I'm not convinced either are doing that but it's a nice to have for me not a core so I will report and leave it at that.
_______________________________________________
http://x-query.com/mailman/listinfo/talk
Ihe Onwuka
2014-01-02 17:30:53 UTC
Permalink
Yes now that you explain it I can see. It is logical but so unfortunate.
One of those counting the stairs as you climb them moments.
Post by Ihe Onwuka
Post by Ihe Onwuka
The idea was to have returned the position of the instance of C that was
found within it's parent.
That's not what the position() function does. To get the position of a
node $N among the children of its parent, use
count($N/preceding-sibling::node())+1
position() used on the rhs of "/" returns the position of the context item
among the items selected; it will always be an ascending sequence starting
at 1.
Michael Kay
Saxonica
<A name="me"><B><C score="" /><D>some content</D></B><B><C score="44"
/><D>some content</D></B></A>/
Now look what Saxon 9.3.0.5 gives for the position attribute
<g><x position="1" name="me"/><C score="44"/></g>
and eXist 3.0
<g>
<x name="me" position="0"/>
<C score="44"/>
</g>
The idea was to have returned the position of the instance of C that was
found within it's parent. I'm not convinced either are doing that but it's
a nice to have for me not a core so I will report and leave it at that.
_______________________________________________
http://x-query.com/mailman/listinfo/talk
Loading...