XPath/Namespace bug...
Having trouble installing Oxygen? Got a bug to report? Post it all here.
XPath/Namespace bug...
Post by TheIdeaMan »
To select elements using the XPath field from a document that has mixed namespaces you have to use an "empty" namespace to select elements from the defaul namespace.
Example
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/1.0">
<head>
<title>My Page</title>
<dc:Author>Benjamin Young</dc:Author>
</head>
....
</html>
To select the "dc:Author" element I can use //dc:Author.
To select the html "title" element I have to us //:title.
It would be best to remove the need to use a ":" when selecting from the default namespace.
Thanks,

Example
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/1.0">
<head>
<title>My Page</title>
<dc:Author>Benjamin Young</dc:Author>
</head>
....
</html>
To select the "dc:Author" element I can use //dc:Author.
To select the html "title" element I have to us //:title.
It would be best to remove the need to use a ":" when selecting from the default namespace.
Thanks,

-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi,
There is no specified way to select elements from the default namespace using XPath, the fact that you can do this with <oXygen/> using ":" before the element name is just a Xalan side effect - so it is not portable. You should define a proxy for the default namespace and use that in your XPath:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/1.0">
and use //html:title
If en element appears in an XPath without proxy then this means it is from no namespace, so we cannot change this to be the default namespace.
Best Regards,
George
There is no specified way to select elements from the default namespace using XPath, the fact that you can do this with <oXygen/> using ":" before the element name is just a Xalan side effect - so it is not portable. You should define a proxy for the default namespace and use that in your XPath:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/1.0">
and use //html:title
If en element appears in an XPath without proxy then this means it is from no namespace, so we cannot change this to be the default namespace.
Best Regards,
George
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