[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-dev
Subject:    RE: XPath problem in XMLBeans Urgent
From:       "Yana Kadiyska" <ykadiysk () bea ! com>
Date:       2004-11-24 18:46:09
Message-ID: 4B2B4C417991364996F035E1EE39E2E1023C0E1C () uskiex01 ! amer ! bea ! com
[Download RAW message or body]

Hi, namespaces are not well-supported in the current jaxen hookup. You
can search the mailing lists-I think the user mailing list in
particular-people have posted their solutions/patches, and there has
been a fairly lengthy discussion of the issue/bug and potential
workarounds . We are working on a long term solution for this
problem-will be available probably sometime in Dec-January.

 

For now, you can try your query without the namespaces:

 

".//Child/DataElement"

 

This query is not necessarily equivalent to yours, of course, but it
could work-don't know if what you're showing is all of your data or a
snippet? The not-so-easy solution is to remove all namespaces and issue
the query.

 

-Yana

 

  _____  

From: puneet sharma [mailto:puneet_jee@yahoo.com] 
Sent: Wednesday, November 24, 2004 4:36 AM
To: dev@xmlbeans.apache.org
Subject: 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! <http://my.yahoo.com>  - What will yours do?


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:st1="urn:schemas-microsoft-com:office:smarttags" \
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"
 downloadurl="http://www.5iantlavalamp.com/"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PersonName" downloadurl="http://www.microsoft.com"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:blue;
	text-decoration:underline;}
p
	{mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman";}
span.EmailStyle19
	{mso-style-type:personal-reply;
	font-family:Arial;
	color:navy;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=blue>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Hi, namespaces are not well-supported in
the current jaxen hookup. You can search the mailing lists&#8212;I think the
user mailing list in particular&#8212;people have posted their
solutions/patches, and there has been a fairly lengthy discussion of the issue/bug
and potential workarounds . We are working on a long term solution for this
problem&#8212;will be available probably sometime in \
Dec-January.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>For now, you can try your query without
the namespaces:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&#8220;.//Child/DataElement&quot;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>This query is not necessarily equivalent to yours, of course, but it
could work&#8212;don&#8217;t know if what you&#8217;re showing is all of your
data or a snippet? The not-so-easy solution is to remove all namespaces and
issue the query.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>-<st1:place w:st="on">Yana</st1:place></span></font><font size=2
color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> puneet sharma
[mailto:puneet_jee@yahoo.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, November 24, 2004
4:36 AM<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName \
w:st="on">dev@xmlbeans.apache.org</st1:PersonName><br> <b><span \
style='font-weight:bold'>Subject:</span></b> XPath problem in XMLBeans Urgent \
</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Hi All,<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>I am facing some problems with XPath in XMLBeans. I have
Jaxen-1.1-beta-2.jar in classpath. <br>
<br>
I have following XML structure. <br>
<br>
&lt;nsp:Parent xmlns:nsp=&quot;http://www.mycmp.com&quot;&gt; <br>
&lt;Child&gt; <br>
&lt;DataElement&gt;SomeValue&lt;/DataElement&gt; <br>
&lt;/Child&gt; <br>
&lt;/nsp:envelope&gt; <br>
<br>
The following expression works fine <br>
String queryExpression =&quot;declare namespace nsp='http://www.mycmp.com&quot;
+ <br>
&quot;$this/nsp:Parent/Child/DataElement&quot; ; <br>
<br>
<br>
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 <br>
<br>
String queryExpression =&quot;declare namespace
nsp='http://www.mycmp.com;&quot; + <br>
&quot;$this/nsp:Parent/*[local-name() = 'Child']/DataElement&quot; ; <br>
<br>
<strong><b><font face="Times New Roman">But this does not work. \
</font></b></strong><br> <br>
In the following code the returnedObjects in blank <br>
EnvelopeDocument parentDoc = EnvelopeDocument.Factory.parse(file); <br>
XmlObject returnedObjects[] = parentDoc.selectPath(queryExpression) ; <br>
<br>
I am not getting any exceptions also. Previously when xbean_xpath.jar was not
there in the classpath I was getting &quot;expression is too complex&quot;
Exception.<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>This is&nbsp;very urgent for me. <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Thanks<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Puneet<o:p></o:p></span></font></p>

</div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=1 width="100%" align=center>

</span></font></div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Do you Yahoo!?<br>
The <a href="http://my.yahoo.com">all-new My Yahoo!</a> &#8211; What will yours
do?<o:p></o:p></span></font></p>

</div>

</body>

</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic