Page 1 of 1

xPath //elementName expression "stopped" working

Posted: Tue Oct 05, 2021 1:31 am
by ari
let's say I would like to target all `head` elements within a TEI XML document; I would normally use the expression

Code: Select all

//head
for some unclear ( to me at least) reason and after performing some queries in the same session this query stopped working ; so I quit the app reopened the file but it still wouldn't work either on the xPath search nor when using XPath XQuery Builder instead whenever I ran a query I got the following pop up message
The XPath query returned no results. XPath scope: Current File
XML Refactoring still worked fine…

I created a new TEI All document using oXygen's file templates, but I still had the same issue

As I was digging in oXygen's forum I came across an old post and I tried the following expression

Code: Select all

//default:head
which gave me the correct results

However I've never had to use a prefix before while using the file templates and sticking only to TEI, am I missing something super obvious? Is there a setting I should check?

Re: xPath //elementName expression "stopped" working

Posted: Tue Oct 05, 2021 9:50 am
by adrian
Hello,

Normally XPath 2.0 expressions should be namespace-qualified when working with documents that have namespaces (like TEI). However, by default Oxygen tries to make XPath easier to use and is configured to use the default namespace of the root element in the document as the default namespace for XPath 2.0 expressions.
I'm guessing you have changed this option, menu > Options > Preferences, XML / XSLT-XQuery / XPath, XPath Default Namespace. For the default behavior it should be set to "Use the default namespace from the root element". Or you can press the "Restore Defaults" button from that option page. This affects both the XPath toolbar and the XPath/XQuery Builder.

Regards,
Adrian

Re: xPath //elementName expression "stopped" working

Posted: Tue Oct 05, 2021 10:19 am
by ari
I'm guessing you have changed this option, menu > Options > Preferences, XML / XSLT-XQuery / XPath, XPath Default Namespace. For the default behavior it should be set to "Use the default namespace from the root element".
That was it… thank you!!