Page 1 of 1

xpath problem

Posted: Wed Dec 13, 2006 2:57 pm
by b6phb80
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>

Posted: Wed Dec 13, 2006 6:24 pm
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

Code: Select all

//NISSE/AppHeader/Origin/text()
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

Posted: Thu Dec 14, 2006 10:12 am
by b6phb80
Thx Sorin for the perfect explained answer !