You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Mohana Ramaratnam <mo...@npg.wustl.edu> on 2006/07/18 17:06:09 UTC

XPath and Namespace

If I have an instance document like so:

 

<Pipeline xmlns="http://nrg.wustl.edu/pipeline"
xmlns:prov="http://www.nbirn.net/prov"
xmlns:xdat="http://nrg.wustl.edu/xdat"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://nrg.wustl.edu/xnat

C:\\schema\pipeline.xsd">

<parameters>

             <parameter>

                    <name>fidldir</name>

                    <value>/fidl/fidl_2.60/bin</value>

             </parameter>

             <parameter>

                    <name>rlbdir</name>

 
<value>/Pipeline/parameters/parameter[name='fidldir']/value/text()
</value>

             </parameter>

</parameters>

</Pipeline>

 

And I want to evaluate the xpath expression:

 

/Pipeline/parameters/parameter[name='fidldir']/value/text()

 

Is it necessary for the namespace prefix of pipeline: to be present in
the expression
/Pipeline/parameters/parameter[name='fidldir']/value/text() for xpath to
be evaluated correctly?

 

Ie should the expression be:

 

/pipeline:Pipeline/pipeline:parameters/pipeline:parameter[pipeline:name=
'fidldir']/pipeline:value/text() 

 

(as in the samples)

 

How do I set the namespace so that the instance document xpath
expression need not have the namespace prefixed. I have looked into
XmlOptions and didn't find anything useful.

 

 

 


RE: XPath and Namespace

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
See my previous post (7/21) for an example provided by Tony Dean with
namespaces in XPaths. Here is the relevant code:
 
> Sring ns = "declare namespace ns='http://tempuri.org/myService';";

> String xpath = ns +

> "$this/ns:copyintoout/ns:parameters[@myname='Tony']";

> XmlObject[] selections = soapBody.selectPath(xpath);

There is nothing for that in XmlOptions because there is a
"semi-standard" way of doing it by using 'declare namespace
pipeline="http://nrg.wustl.edu/pipeline"' and we stick to that.
 
Hope this helps,
Radu

 
________________________________

From: Mohana Ramaratnam [mailto:mohanar@npg.wustl.edu] 
Sent: Tuesday, July 18, 2006 8:06 AM
To: user@xmlbeans.apache.org
Subject: XPath and Namespace



If I have an instance document like so:

 

<Pipeline xmlns="http://nrg.wustl.edu/pipeline"
xmlns:prov="http://www.nbirn.net/prov"
xmlns:xdat="http://nrg.wustl.edu/xdat"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://nrg.wustl.edu/xnat

C:\\schema\pipeline.xsd">

<parameters>

             <parameter>

                    <name>fidldir</name>

                    <value>/fidl/fidl_2.60/bin</value>

             </parameter>

             <parameter>

                    <name>rlbdir</name>

 
<value>/Pipeline/parameters/parameter[name='fidldir']/value/text()
</value>

             </parameter>

</parameters>

</Pipeline>

 

And I want to evaluate the xpath expression:

 

/Pipeline/parameters/parameter[name='fidldir']/value/text()

 

Is it necessary for the namespace prefix of pipeline: to be present in
the expression
/Pipeline/parameters/parameter[name='fidldir']/value/text() for xpath to
be evaluated correctly?

 

Ie should the expression be:

 

/pipeline:Pipeline/pipeline:parameters/pipeline:parameter[pipeline:name=
'fidldir']/pipeline:value/text() 

 

(as in the samples)

 

How do I set the namespace so that the instance document xpath
expression need not have the namespace prefixed. I have looked into
XmlOptions and didn't find anything useful.

 

 

 

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.