could do the following :-
Collection col1=null;
Collection col2=null;
String xpath="your xpath";
col1=DatabaseManager.getCollection("xmldb:xindice:///root");
String allCollections[]=col1.listChildCollections();
for (int i=0;i<allCollections.length();i++) {
col2=DatabaseManager.getCollection("xmldb:xindice:///root/"+allCollections[i
]);
XPathQueryService service =(XPathQueryService)
col2.getService("XPathQueryService", "1.0");
ResourceSet resultSet = service.query(xpath);
ResourceIterator results = resultSet.getIterator();
// your code.................
}
this is the dirty way...you get different resultset objects.
is there an elegant way in api?
i am a newbie..somehow managing through this work-around.
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: Friday, May 17, 2002 1:37 PM
> To: [email protected]
> Subject: RE: Query across collections?
>
>
> Hi,
>
> Good question - this is something I would also be very
> interested to know
> about ... So if anyone on this list knows how this could be
> implemented,
> please let us know..
>
> From my current understanding each collection is treated as one large
> separate document, so XPath can only be used on each
> collection at a time.
> Cross collection querying would be very useful, and would allow us to
> organise data more logically into multiple collections (for
> example one
> collection of User documents, one collection for auditing
> info etc...) Does
> anyone know if this can be done??
>
> Thanks for any answer in advance,
> Peter
>
> -----Original Message-----
> From: Michael Cortez [mailto:[EMAIL PROTECTED]
> Sent: 17 May 2002 01:51
> To: [email protected]
> Subject: Query across collections?
>
>
> Is it possible to query across collections with xpath?
>
> i.e.
>
> root
> -- collection1
> -- -- doc1
> -- -- -- <node>1</node>
> -- -- -- <node>2</node>
> -- collection2
> -- -- doc2
> -- -- -- <node>3</node>
> -- -- -- <node>4</node>
> -- -- doc3
> -- -- -- <node>5</node>
> -- -- -- <node>6</node>
>
>
> I would like to get all 6 node elements, from all three
> documents, from both
> collections.
>
>
> To get the nodes right now I have to do (from Xindice):
>
> xmldb:xindice://localhost:4080/db/collection1/#/node
> xmldb:xindice://localhost:4080/db/collection2/#/node
>
>
> I'd like to do something like:
> xmldb:xindice://localhost:4080/db/*/#/node
>
>
> Is that possible?
>
> --
> Mike
>
"THIS E-MAIL MESSAGE ALONG WITH ANY ATTACHMENTS IS INTENDED ONLY FOR THE
ADDRESSEE and may contain confidential and privileged information.
If the reader of this message is not the intended recipient,
you are notified that any dissemination, distribution or copy of this
communication is strictly Prohibited.
If you have received this message by error, please notify us
immediately, return the original mail to the sender and delete the
message from your system."