XPath expression -- problem with namespace
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 15
- Joined: Thu Jun 10, 2004 1:51 pm
- Location: ETH Zurich, Switzerland
XPath expression -- problem with namespace
I have no idea what is wrong here. Consider this XML Schema
If I write this //xs:element[xs:complexType[@*='node']] XPath expression to the XPath "comboBox" it corectly returns /xs:schema[1]/xs:element[1]. However if I change "*" for "dm:displayType" i.e. use the XPath expression //xs:element[xs:complexType[@dm:displayType='node'] Oxygen reports the following: Invalid XPath expression Prefix must resolve to a namespace dm:
Can anyone provide me with some hint?
Thanks a lot!
K!lhor
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright P&P Software GmbH (Zurich, Switzerland) -->
<xs:schema
targetNamespace="http://www.pnp-software.com/fmt/fm"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dm="http://www.pnp-software.com/fmt/displayModel"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="FeatureNode">
<xs:complexType dm:displayType="node">
<xs:choice>
<xs:element name="foo">
<xs:complexType>
<xs:choice>
<xs:element name="bar" type="xs:string"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Can anyone provide me with some hint?
Thanks a lot!
K!lhor
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi,
Oxygen detects only the prefixes used in elements when it evaluates XPath expressions. To workaround this you can add an annotation and use a dummy element from that namespace inside appinfo:
<xs:schema targetNamespace="http://www.pnp-software.com/fmt/fm"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dm="http://www.pnp-software.com/fmt/displayModel"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:annotation>
<xs:appinfo>
<dm:test/>
</xs:appinfo>
</xs:annotation>
...
Another workaround is to check only the local name:
//xs:element[xs:complexType[@*[local-name()='displayType']='node']]
Best Regards,
George
Oxygen detects only the prefixes used in elements when it evaluates XPath expressions. To workaround this you can add an annotation and use a dummy element from that namespace inside appinfo:
<xs:schema targetNamespace="http://www.pnp-software.com/fmt/fm"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dm="http://www.pnp-software.com/fmt/displayModel"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:annotation>
<xs:appinfo>
<dm:test/>
</xs:appinfo>
</xs:annotation>
...
Another workaround is to check only the local name:
//xs:element[xs:complexType[@*[local-name()='displayType']='node']]
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