Thanks, I know my problem is the query format
Can anyone drive me to a good tutorial of XPATH query
here the different query I tried:
System.out.println("ADDING MESSAGE FROM PATH & NAME");
MessageDB.addDocument(mailDirectory +
"dariusjbosSatAug13235020BST2005.xml");
//DOESN'T WORK (But it s fine, I suppose KEY ID is better as the result from
any query is the KEY.
System.out.println("RETRIEVE MESSAGE FROM NAME");
MessageDB.retrieveDocument("dariusjbosSatAug13235020BST2005.xml");
//WORKS BECAUSE it exists
System.out.println("RETRIEVE MESSAGE FROM KEY");
MessageDB.retrieveDocument("0601a7c0664aa59900000105bf073edf");
// WORKS TOO, OUTPUT is a list of KEY Document
System.out.println("COUNT MESSAGE FROM DB/MAIL");
MessageDB.queryCollection("count(//Message)");
//WORKS, OUTPUT is a list of KEY Document where dariusjbos appears
System.out.println("QUERY MESSAGE WITH DARIUSJBOS AS FROM");
MessageDB.queryCollection("/from/Address/name='dariusjbos'");
//DOESN'T Return ANything but at least no error from the query format
System.out.println("QUERY MESSAGE WITH CONTENT TYPE TEXT");
MessageDB.queryCollection("/[EMAIL PROTECTED]'text/plain']");
//DOESN'T Return ANything but at least no error from the query format
System.out.println("QUERY MESSAGE WITH [EMAIL PROTECTED] AS FROM");
MessageDB.queryCollection("/from/Address[adrs='mailto:[EMAIL
PROTECTED]']/text()");
//DOESN'T WORK and ERROR for the query
System.out.println("QUERY STRING MESSAGE WITH CONTENT TYPE TEXT");
MessageDB.queryCollection("string(/[EMAIL PROTECTED]'text/plain']");
//DOESN'T Return ANything but at least no error from the query format
System.out.println("QUERY MESSAGE WITH DARIUSJBOS AS FROM v2");
MessageDB.queryCollection("/from/Address/name[. ='dariusjbos']");
So, for summary, can anyone as a good tuto reference website for xpath query
because i tried some, and most of the example doesn't fit (like the one with
[. =dariusjbos])
What I want, is query adrs and the date from my xml, I suppose it will
return a list of Key Document from Xindice DB and I have to manage from
these Key to retrieve the full document
Is there any way to only retrieve part of the XML queried?
It s a mail application so from all the mail stored in Xindice, I want to
create some sort of listing of message
Thanks in advance
<BLOCKQUOTE style='PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #A0C6E5
2px solid; MARGIN-RIGHT: 0px'><font
style='FONT-SIZE:11px;FONT-FAMILY:tahoma,sans-serif'><hr color=#A0C6E5
size=1>
From: <i>"Lisa McCabe"
<[EMAIL PROTECTED]></i><br>Reply-To:
<i>xindice-users@xml.apache.org</i><br>To:
<i><xindice-users@xml.apache.org></i><br>Subject: <i>Re: Problem to
Xquery a document from xindice collection</i><br>Date: <i>Mon, 15 Aug 2005
20:56:51 -0400</i><br>MIME-Version: <i>1.0</i><br>Received: <i>from
mail.apache.org ([209.237.227.199]) by MC8-F24.hotmail.com with Microsoft
SMTPSVC(6.0.3790.211); Mon, 15 Aug 2005 17:57:11 -0700</i><br>Received:
<i>(qmail 60799 invoked by uid 500); 16 Aug 2005 00:57:10
-0000</i><br>Received: <i>(qmail 60786 invoked by uid 99); 16 Aug 2005
00:57:10 -0000</i><br>Received: <i>from asf.osuosl.org (HELO
asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP;
Mon, 15 Aug 2005 17:57:10 -0700</i><br>Received: <i>pass (asf.osuosl.org:
local policy)</i><br>Received: <i>from [24.248.88.131] (HELO
mail.myeastern.com) (24.248.88.131) by apache.org (qpsmtpd/0.29) with ESMTP;
Mon, 15 Aug 2005 17:57:29 -0700</i><br>Received: <i>from MegaCool
(unverified [66.212.211.142]) by myeastern-dot-com (MyEastern Mail -
www.myeastern.com) with ESMTP id 24666502 for
<xindice-users@xml.apache.org>; Mon, 15 Aug 2005 20:57:01
-0400</i><br>Hi,<br><br>Did you try the same query using the commandline
Xindice to see if your<br>xpath query works? That helps me in firguring out
my problems. I am doing<br>the same type of stuff and compared our code -
yours is the same as mine so<br>it should work.<br><br>-Lisa
McCabe<br><br>PS Good luck meeting your deadline!<br><br>----- Original
Message -----<br>From: "johan bos"
<[EMAIL PROTECTED]><br>To:
<xindice-users@xml.apache.org><br>Sent: Monday, August 15, 2005 1:57
PM<br>Subject: Problem to Xquery a document from xindice
collection<br><br><br> ><br> > Hello Everyone,<br> ><br> > Here
my problem,<br> > I can connect and create a collection (mail) in
xindice 1.1 (from<br> > within my<br> > servlet (tomcat 5))<br> > I
can add document to this collection (the ugly browser let me see them)<br>
><br> > but when i try to make a query using the example function for
quering<br> > xindice, i got an error such as below: (some of the message
are from my<br> > debug)<br> ><br> ><br> > trying to register
database<br> > Database xmldb:xindice://localhost:8080/db is
connected<br> > Collection xmldb:xindice://localhost:8080/db is
connected<br> > Collection mail already created<br> >
org.xmldb.api.base.XMLDBException: org.apache.xmlrpc.XmlRpcException:<br>
> Error<br> > Compiling XPath Expression: Une étape d'emplacement
était attendue après<br> > le<br> > jeton ''/'' ou ''//''.<br> >
at<br>
><br>org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.runRemoteCommand(Colle<br>ctionImpl.java:119)<br>
> at<br>
><br>org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.query(CollectionImpl.j<br>ava:515)<br>
> at<br>
><br>org.apache.xindice.client.xmldb.XindiceCollection.query(XindiceCollection.ja<br>va:259)<br>
> at<br>
><br>org.apache.xindice.client.xmldb.services.QueryService.query(QueryService.jav<br>a:90)<br>
> at jmms.MessageDB.queryCollection(MessageDB.java:163)<br> > at
jmms.JMMSServlet.doMessageToDB(JMMSServlet.java:1009)<br> > at
jmms.JMMSServlet.doPost(JMMSServlet.java:342)<br> > at
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)<br> > at
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)<br> > at<br>
><br>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application<br>FilterChain.java:252)<br>
> at<br>
><br>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh<br>ain.java:173)<br>
> at<br>
><br>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja<br>va:213)<br>
> at<br>
><br>org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja<br>va:178)<br>
> at<br>
><br>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126<br>)<br>
> at<br>
><br>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105<br>)<br>
> at<br>
><br>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java<br>:107)<br>
> at<br>
><br>org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)<br>
> at<br> >
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)<br>
> at<br>
><br>org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne<br>ction(Http11Protocol.java:744)<br>
> at<br>
><br>org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.jav<br>a:527)<br>
> at<br>
><br>org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWo<br>rkerThread.java:80)<br>
> at<br>
><br>org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav<br>a:684)<br>
> at java.lang.Thread.run(Unknown Source)<br> > Query
/mail/Message/from/Address/[name='dariusjbos'] return an error<br> >
XML:DB Exception occured 1 org.apache.xmlrpc.XmlRpcException: Error<br> >
Compiling XPath Expression: Une étape d'emplacement était attendue après<br>
> le<br> > jeton ''/'' ou ''//''.<br> ><br> > the xml document i
try to query look like this:<br> > <?xml version="1.0"
encoding="UTF-8"?><br> > <Message
xmlns="URN:ietf:params:email-xml:"<br> >
rfc822="URN:ietf:params:rfc822:"><br> > <date>Mon
Aug 15 19:03:47 CEST 2005</date><br> > <from><br> >
<Address><br> >
<adrs>mailto:[EMAIL PROTECTED]</adrs><br> >
<name>dariusjbos</name><br> > </Address><br>
> </from><br> > </Message><br> ><br> > find
after the function i use to query the mail collection under db:<br> ><br>
> public static void queryCollection()throws Exception {<br> >
Collection col = null;<br> > try {<br> > String
driver =<br> >
"org.apache.xindice.client.xmldb.DatabaseImpl";<br> >
Class c = Class.forName(driver);<br> ><br> > Database
database = (Database) c.newInstance();<br> >
DatabaseManager.registerDatabase(database);<br> ><br> > col
=<br> >
DatabaseManager.getCollection("xmldb:xindice://localhost:8080/db/mail");<br>
><br> > String xpath =
"//Message/from/Address/[name='dariusjbos']";<br> >
XPathQueryService service =<br> > (XPathQueryService)
col.getService("XPathQueryService",<br> > "1.0");<br>
> ResourceSet resultSet = service.query(xpath);<br> >
ResourceIterator results = resultSet.getIterator();<br> >
while (results.hasMoreResources()) {<br> > Resource res =
results.nextResource();<br> > System.out.println((String)
res.getContent());<br> > }<br> > }<br> >
catch (XMLDBException e) {<br> >
System.err.println("XML:DB Exception occurred " + e.errorCode<br>
> +<br> > "" + e.getMessage());<br> > }<br> >
finally {<br> > if (col != null) {<br> >
col.close();<br> > }<br> > }<br> > }<br>
><br> > please I really need to pass this problem (deadline in 3
days)<br> ><br> > thanks in advance<br> ><br>
><br><br></font></BLOCKQUOTE>