Strange XPath Behaviour

Issues related to W3C XQuery.
jdonges
Posts: 8
Joined: Mon Dec 16, 2019 3:01 pm

Strange XPath Behaviour

Post by jdonges »

Hello,

In Oxygen 25 and 26 we encountered a strange behavior when evaluating an xpath expression with the XPath/XQuery builder.
We want to select all attributes in the entire document except the first attribute of each element with this expression:

Code: Select all

 //@*[position()>1] 
The result is confusing. It selects the first attributes except for the image element in line 13 (blue arrow).
OxygenScreenshot.png
OxygenScreenshot.png (52.08 KiB) Viewed 1647 times

I have tested the expression at https://www.videlibri.de/cgi-bin/xidelcgi with the same input file.
It gives the expected result there:
grafik.png
grafik.png (13.83 KiB) Viewed 1647 times
Could this be a bug? Or can you explain the result the XPath builder in Oxygen returns here?

Thanks in advance and regards
Jörn
Attachments
MicrosoftTeams-image.png
MicrosoftTeams-image.png (52.08 KiB) Viewed 1647 times
Mircea
Posts: 131
Joined: Tue Mar 25, 2003 11:21 am

Re: Strange XPath Behaviour

Post by Mircea »

Hello Jörn,

Please consider using the XPath 3.1 SA engine from the drop-down menu instead of XPath 3.1.
The results should be as expected.

Regards,
Mircea
Mircea Enachescu
<oXygen> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
tavy
Posts: 365
Joined: Thu Jul 01, 2004 12:29 pm

Re: Strange XPath Behaviour

Post by tavy »

Hello,

It seems that the position() function take into account also the default attributes from the schema, even they are not in the document. For example in the "concept" element you have the 4 attributes: class, ditaarch:DITAArchVersion, domains, and id. You can use the following XPath expression "//concept/@*/name()" to get the list of attributes for the "concept" element.
Therefore, in your example the id attribute is on position 4, and this is why is returned by the XPath expression. When "XPath 3.1 SA engine" is used, the default attributes are returned as last attributes in the list.

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply