xpath problem
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 2
- Joined: Wed Dec 13, 2006 2:51 pm
xpath problem
This is my xml. With the build in xpath (i prefer 1.0) I want to select nodes which are after the node NISSE. Because there is a namespace in that node, i can't get the nodes which are in this part of the xml.
Any suggestion p.ex. how i can get the text from the node Origin which is in the node AppHeader ?
Thanks a lot for your answers ...
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://www.rsvz-inasti.fgov.be/schemas/ ... es/Mailbox"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<Origin>2000</Origin>
<Destination>003X</Destination>
</Header>
<Body>
<Mailbox>
<MailboxNbr>000000000000128</MailboxNbr>
<MessageCount>000000000000017</MessageCount>
<CreationDate>2006-12-12</CreationDate>
<CreationTime>12:47:21</CreationTime>
<Message>
<NISSE xmlns="http://www.rsvz-inasti.fgov.be/schemas/ ... /Transport">
<AppHeader>
<DocumentId>ST2B</DocumentId>
<Origin>PENS</Origin>
<Destination>003</Destination>
<VersionNbr>1.0</VersionNbr>
</AppHeader>
</NISSE>
</Message>
</Mailbox>
</Body>
</Envelope>
Any suggestion p.ex. how i can get the text from the node Origin which is in the node AppHeader ?
Thanks a lot for your answers ...
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://www.rsvz-inasti.fgov.be/schemas/ ... es/Mailbox"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<Origin>2000</Origin>
<Destination>003X</Destination>
</Header>
<Body>
<Mailbox>
<MailboxNbr>000000000000128</MailboxNbr>
<MessageCount>000000000000017</MessageCount>
<CreationDate>2006-12-12</CreationDate>
<CreationTime>12:47:21</CreationTime>
<Message>
<NISSE xmlns="http://www.rsvz-inasti.fgov.be/schemas/ ... /Transport">
<AppHeader>
<DocumentId>ST2B</DocumentId>
<Origin>PENS</Origin>
<Destination>003</Destination>
<VersionNbr>1.0</VersionNbr>
</AppHeader>
</NISSE>
</Message>
</Mailbox>
</Body>
</Envelope>
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
The XPath toolbar of oXygen uses the namespace prefixes defined in your XML document. The namespace of the NISSE element (http://www.rsvz-inasti.fgov.be/schemas/ ... /Transport) is default namespace. The XPath 1.0 language does not support default namespaces so you cannot query NISSE or child elements of NISSE using XPath 1.0. You have to use XPath 2.0. Because you do not define a prefix for this namespace in your document you have to set it as the default namespace for XPath 2.0 queries in Options -> Preferences -> XML -> XSLT-FO-XQuery -> XPath -> XPath Default Namespace (only for XPath 2.0) -> Other. Press OK in the Preferences dialog, enter the query
in the XPath toolbar, select XPath 2.0 and run the query. The result is the text child of the Origin element that you wanted and is displayed in a results view at the bottom of the oXygen window. Click on the row of the results view to highlight the result in the editor panel.
Regards,
Sorin
The XPath toolbar of oXygen uses the namespace prefixes defined in your XML document. The namespace of the NISSE element (http://www.rsvz-inasti.fgov.be/schemas/ ... /Transport) is default namespace. The XPath 1.0 language does not support default namespaces so you cannot query NISSE or child elements of NISSE using XPath 1.0. You have to use XPath 2.0. Because you do not define a prefix for this namespace in your document you have to set it as the default namespace for XPath 2.0 queries in Options -> Preferences -> XML -> XSLT-FO-XQuery -> XPath -> XPath Default Namespace (only for XPath 2.0) -> Other. Press OK in the Preferences dialog, enter the query
Code: Select all
//NISSE/AppHeader/Origin/text()
Regards,
Sorin
Return to “General XML Questions”
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