xpath query on xml documents with multiple namespaces
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 5
- Joined: Mon Jul 19, 2004 8:45 pm
xpath query on xml documents with multiple namespaces
using oxygenxml 9.1 on eclipse 3.3
In the xml editor:
trying to query with xpath (ctrl-shift-/) :
//ConversionRateResult -- gives "no results"
-- why??
if i would change the xml not to use a prefix for the inner namespace (such as ns0):
then //ns0:ConversionRateResult
yields: "Invalid XPath expression Prefix must resolve to a namespace: ns0"
Anything that I am doing wrong?
Adrian.
In the xml editor:
Code: Select all
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<ConversionRateResponse xmlns="http://www.webserviceX.NET/">
<ConversionRateResult>3.9455</ConversionRateResult>
</ConversionRateResponse>
</soap:Body>
</soap:Envelope>
//ConversionRateResult -- gives "no results"
-- why??
if i would change the xml not to use a prefix for the inner namespace (such as ns0):
Code: Select all
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<ns0:ConversionRateResponse xmlns:ns0="http://www.webserviceX.NET/">
<ns0:ConversionRateResult>3.9455</ns0:ConversionRateResult>
</ns0:ConversionRateResponse>
</soap:Body>
</soap:Envelope>
yields: "Invalid XPath expression Prefix must resolve to a namespace: ns0"
Anything that I am doing wrong?
Adrian.
-
- Posts: 5
- Joined: Mon Jul 19, 2004 8:45 pm
however if i change the xml to look like:
then it works as expected...
Code: Select all
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns0="http://www.webserviceX.NET/">
<soap:Body>
<ns0:ConversionRateResponse>
<ns0:ConversionRateResult>3.9455</ns0:ConversionRateResult>
</ns0:ConversionRateResponse>
</soap:Body>
</soap:Envelope>
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi Adrian,
An XPath expression is executed in a certain namespace context. oXygen computes the namespace context using the namespace declarations from the document root element and the namespace declarations defined in options (Window->Preferences -- oXygen / XML / XSLT-FO-XQuery / XPath -- Default prefix-namespace mappings.
Note also that XPath 1.0 does not have a notion of default namespace, name tests without a prefix are always in no namespace. XPath 2.0 introduced support for default namespace in XPath expressions and oXygen has a few options that allow you to control how that is determined, see the same preferences page Window->Preferences -- oXygen / XML / XSLT-FO-XQuery / XPath, the XPath default namespace section. By default oXygen will add as default namespace the namespace of the root element only if that is declared as default namespace.
I hope the above explains all the cases you encountered. If you think you need more details about one of them, or about some other case just let me know.
Best Regards,
George
An XPath expression is executed in a certain namespace context. oXygen computes the namespace context using the namespace declarations from the document root element and the namespace declarations defined in options (Window->Preferences -- oXygen / XML / XSLT-FO-XQuery / XPath -- Default prefix-namespace mappings.
Note also that XPath 1.0 does not have a notion of default namespace, name tests without a prefix are always in no namespace. XPath 2.0 introduced support for default namespace in XPath expressions and oXygen has a few options that allow you to control how that is determined, see the same preferences page Window->Preferences -- oXygen / XML / XSLT-FO-XQuery / XPath, the XPath default namespace section. By default oXygen will add as default namespace the namespace of the root element only if that is declared as default namespace.
I hope the above explains all the cases you encountered. If you think you need more details about one of them, or about some other case just let me know.
Best Regards,
George
George Cristian Bina
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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