This executes just fine if run individually on any given file:
//mods:relatedItem/mods:titleInfo[(following-sibling::mods:titleInfo)]/mods:title
but if I tell it to run on all opened files (which are all the same kind of xml metadata)
I get this error:
XPath failed du to: Prefix mods has not been declared.
the mods comes from xmlns:mods="http://www.loc.gov/mods/v3 presumably.
If I remove the mods: from the node names the query runs but doesn't work.
Xpath query fails if "all opened files"
-
- Posts: 384
- Joined: Thu Aug 21, 2003 11:36 am
- Location: Craiova
- Contact:
Re: Xpath query fails if "all opened files"
The composition of the prefix-namespace mappings used when executing an XPath expression is done by following the next rules:
* the mappings from the XML/XSLT-FO-XQuery/XPath preferences page are added first - see the Default prefix-namespace mappings and the XPath default namespace sections;
* if the XPath execution scope is Current file, then the prefix-namespace mappings are enriched with the ones declared on the root element of the current file.
For more details please go to http://www.oxygenxml.com/doc/versions/1 ... xpath.html
* the mappings from the XML/XSLT-FO-XQuery/XPath preferences page are added first - see the Default prefix-namespace mappings and the XPath default namespace sections;
* if the XPath execution scope is Current file, then the prefix-namespace mappings are enriched with the ones declared on the root element of the current file.
For more details please go to http://www.oxygenxml.com/doc/versions/1 ... xpath.html
This works because the namespace for the mods prefix is detected from the current file when the execution scope is Current File.luxlunae wrote:This executes just fine if run individually on any given file:
//mods:relatedItem/mods:titleInfo[(following-sibling::mods:titleInfo)]/mods:title
When running an XPath expression over multiple files, the namespace-prefix mappings used by the processor are the ones declared in the Default prefix-namespace mappings table from the XML/XSLT-FO-XQuery/XPath preferences page. So, in your case you have to add a new entry (mods -> http://www.loc.gov/mods/v3) in this table.luxlunae wrote: but if I tell it to run on all opened files (which are all the same kind of xml metadata)
I get this error:
XPath failed du to: Prefix mods has not been declared.
The XPath default namespace is computed accordingly with the XPath Default Namespace option from the XML/XSLT-FO-XQuery/XPath preferences page. In your case you can switch to 'This Namespace' entry and set its value to http://www.loc.gov/mods/v3.luxlunae wrote: the mods comes from xmlns:mods="http://www.loc.gov/mods/v3 presumably.
If I remove the mods: from the node names the query runs but doesn't work.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Re: Xpath query fails if "all opened files"
It works like magic! Thanks!