Xpath evaluator telling me that a namespace is not declared, but it is

Oxygen general issues.
Posts: 1
Joined: Thu Sep 21, 2023 9:42 pm

Xpath evaluator telling me that a namespace is not declared, but it is

Post by nahumpal »

I feel like I'm going crazy here.

The Xpath evaluator keeps telling me that namespaces that are declared in the document are not declared. For instance I'm trying to evaluate the following Xpath:

Code: Select all

MD_Metadata/contact/CI_ResponsibleParty/individualName[following-sibling::role/CI_RoleCode[text() = 'resourceProvider']]/gco:CharacterString
in a document with this header:

Code: Select all

<MD_Metadata xmlns="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:srv="http://www.isotc211.org/2005/srv" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:gmx="http://www.isotc211.org/2005/gmx" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
But the evaluator keeps telling me "XPath failed due to: Namespace prefix 'gco' has not been declared". This was not a problem until I tried to use the XPath builder to evaluate that XPath across files in a directory. When I tried to do that, I got the same error, and now every time I try to do it in just one xml file I get the same error.
Posts: 359
Joined: Thu Jul 01, 2004 12:29 pm

Re: Xpath evaluator telling me that a namespace is not declared, but it is

Post by tavy »


Probably you changed the XPath scope from "Current File" to "Selected Project Resources". Please note that the namespace is only detected from the file when using the "Current File" scope. To adjust the scope, you have two options: you can either modify it from the XPath toolbar or from the XPath builder. In the XPath toolbar, the drop-down menu will display a different icon before the XPath expression, depending on the scope you have selected. For more information, please refer to our user manual: https://www.oxygenxml.com/doc/versions/ ... xv_cgk_54b

If you wish to utilize a different scope for your XPath, you can declare the namespaces in the XPath Options: https://www.oxygenxml.com/doc/versions/ ... xpath.html

Best Regards,
Octavian Nadolu
<oXygen/> XML Editor
Post Reply