xPath //elementName expression "stopped" working

Having trouble installing Oxygen? Got a bug to report? Post it all here.
ari
Posts: 14
Joined: Sun Apr 01, 2012 1:17 pm

xPath //elementName expression "stopped" working

Post 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?
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: xPath //elementName expression "stopped" working

Post 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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
ari
Posts: 14
Joined: Sun Apr 01, 2012 1:17 pm

Re: xPath //elementName expression "stopped" working

Post 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!!
Post Reply