Mark Fletcher wrote:
> Last night, I stumbled upon something which explains the differing
> behavior between the two xpath expressions. It has to do with the
> filenames of the current document and the "document()" document.
>
> Here's the scenario:
>
> The current file (a DITA map) is named 'b_file.xml'.
>
> This xpath returns the left-hand expression:
>
> ancestor::reltable|document('c_file.xml',.)//shortdesc
>
>
> This xpath doesn't:
>
> ancestor::reltable|document('a_file.xml',.)//shortdesc
>
>
> a_file.xml and c_file.xml are duplicates, located in the same folder.
>
> If the "document()" filename has a lower alphabetical ranking than the
> current document, the "document()" function will always override
> expression that tests the current file.
>
> (By the way, the reason I want to return an empty node is to suppress
> the shortdesc when the topicref is displayed inside a reltable.)
>
Very interesting. At first I didn't believe what you said, but I was
able to reproduce what you described!
Now, once again, there is no bug here:
---
ancestor::reltable|document('c_file.xml',.)//shortdesc
---
return a nodeset and the nodes in this nodeset are sorted in document
order. In the case of the above expression, when the nodeset contains 2
nodes, these nodes don't belong to the same document. In such case, the
nodes are sorted by their documents (and documents are ordered by their
filenames!).
If you want something more reliable, please use:
---
if(ancestor::reltable,ancestor::reltable,document('c_file.xml',.)//shortdesc)
---