Xpath query fails if "all opened files"
Issues related to W3C XQuery.
-
- Posts: 26
- Joined: Wed Jun 17, 2015 10:01 pm
Xpath query fails if "all opened files"
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.
//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.
-
- Posts: 404
- Joined: Thu Aug 21, 2003 11:36 am
- Location: Craiova
- Contact:
Re: Xpath query fails if "all opened files"
Post by radu_pisoi »
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
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service