You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by puneet sharma <pu...@yahoo.com> on 2004/11/24 13:35:43 UTC

XPath problem in XMLBeans Urgent

Hi All,
 
 
I am facing some problems with XPath in XMLBeans. I have Jaxen-1.1-beta-2.jar in classpath. 

I have following XML structure. 

<nsp:Parent xmlns:nsp="http://www.mycmp.com"> 
<Child> 
<DataElement>SomeValue</DataElement> 
</Child> 
</nsp:envelope> 

The following expression works fine 
String queryExpression ="declare namespace nsp='http://www.mycmp.com" + 
"$this/nsp:Parent/Child/DataElement" ; 


In this XML 'Child' element may or may not have namespace prefix (as this XML will come from outside world). According to XSD Child is in the name space. So I tried to use following generic XPath expression 

String queryExpression ="declare namespace nsp='http://www.mycmp.com;" + 
"$this/nsp:Parent/*[local-name() = 'Child']/DataElement" ; 

But this does not work. 

In the following code the returnedObjects in blank 
EnvelopeDocument parentDoc = EnvelopeDocument.Factory.parse(file); 
XmlObject returnedObjects[] = parentDoc.selectPath(queryExpression) ; 

I am not getting any exceptions also. Previously when xbean_xpath.jar was not there in the classpath I was getting "expression is too complex" Exception.
 
 
This is very urgent for me. 
 
Thanks
Puneet

		
---------------------------------
Do you Yahoo!?
 The all-new My Yahoo! � What will yours do?

Re: XPath problem in XMLBeans Urgent

Posted by puneet sharma <pu...@yahoo.com>.
To add in my previous mail
 
I have xbean_xpath.jar in classpath too
 
Thanks
Puneet


puneet sharma <pu...@yahoo.com> wrote:
Hi All,
 
 
I am facing some problems with XPath in XMLBeans. I have Jaxen-1.1-beta-2.jar in classpath. 

I have following XML structure. 

<nsp:Parent xmlns:nsp="http://www.mycmp.com"> 
<Child> 
<DataElement>SomeValue</DataElement> 
</Child> 
</nsp:envelope> 

The following expression works fine 
String queryExpression ="declare namespace nsp='http://www.mycmp.com" + 
"$this/nsp:Parent/Child/DataElement" ; 


In this XML 'Child' element may or may not have namespace prefix (as this XML will come from outside world). According to XSD Child is in the name space. So I tried to use following generic XPath expression 

String queryExpression ="declare namespace nsp='http://www.mycmp.com;" + 
"$this/nsp:Parent/*[local-name() = 'Child']/DataElement" ; 

But this does not work. 

In the following code the returnedObjects in blank 
EnvelopeDocument parentDoc = EnvelopeDocument.Factory.parse(file); 
XmlObject returnedObjects[] = parentDoc.selectPath(queryExpression) ; 

I am not getting any exceptions also. Previously when xbean_xpath.jar was not there in the classpath I was getting "expression is too complex" Exception.
 
 
This is very urgent for me. 
 
Thanks
Puneet


---------------------------------
Do you Yahoo!?
The all-new My Yahoo! � What will yours do?
		
---------------------------------
Do you Yahoo!?
 Yahoo! Mail - Helps protect you from nasty viruses.