You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Gwen G <gg...@hotmail.com> on 2005/05/23 19:13:47 UTC
Xindice1.1b3 and .NET
Hi,
Has anybody tried to use XIndice 1.1b3/b4 with .NET and XML-RPC.NET? Do I
need a Xindice-XML-RPC interface or something similar?
The program I am currently working on (on .net) runs perfectly on XIndice
1.0; however, it does not work on XIndice 1.1b3 at all. It can reach the
server, but that's all (I always get the error "Response from server does
not contain valid XML"). I guess the problem is that I am no longer using
the old Xindice-XML-RPC Interface for Xindice 1.0, since everything else
hasn't changed at all, and the code is very simple. (In addition, this is
the same error I got in XIndice 1.0 before I used the Xindice XML-RPC
Interface for Xindice 1.0). However, I can“t find a newer version of this
interface...
Does anybody know if there is a new version of Xindice XML-RPC Interface for
Xindice 1.1b4? Otherwise, have you ever heard about this problem before, and
do you know how to fix it?
Thanks a lot in advance!
_________________________________________________________________
Descarga gratis la Barra de Herramientas de MSN
http://www.msn.es/usuario/busqueda/barra?XAPID=2031&DI=1055&SU=http%3A//www.hotmail.com&HL=LINKTAG1OPENINGTEXT_MSNBH
Re: how to get collections tree from xindice
Posted by Marcin Goldyn <Ma...@poczta.onet.pl>.
thank u very much Todd i tried this but i got 0 count all the time and i
thought that this wasnt this what i whant but of course it is. It was my
mistake tha i got 0.
thx again
Marcin Goldyn
Re: how to get collections tree from xindice
Posted by Todd Byrne <by...@cns.montana.edu>.
Try collection.getResourceCount() it will return you the number of
documents in the collection and start.getChildCollectionCount() to get
the number of child collections.
Change
//int liczbaDokumentow = (int)kolekcja.getDocumentCount();
to
int liczbaDokumentow = (int)kolekcja.getResourceCount();
And that should get you going.
Todd
Marcin Goldyn wrote:
> i know how to get ChildCollections and built collection tree
> but also i have to get documents stores in particular collections. There
> are methods like getDocumentsCount() and listDocuments() in
> org.apache.xindice.core.Collection class but this class isn`t work with
> org.xmldb.api.DatabaseManager so i cant register database. Maybe there
> is another way to register database using
> org.apache.xindice.core.Collection class? or there is another way to
> listDocumetns and count their number??
>
> DBConnection.java
> package praca.app;
>
>
>
> import org.xmldb.api.base.Database;
> import org.xmldb.api.DatabaseManager;
>
>
>
> public final class DBConnection
> {
> public String addressIP;
> public String port;
> protected static Database db = null;
>
>
>
>
> Database getDB() throws Exception
> {
>
> try
> {
> db =
> (Database)Class.forName("org.apache.xindice.client.xmldb.DatabaseImpl").newInstance();
>
> DatabaseManager.registerDatabase(db);
> }
> catch(Exception e)
> {
> System.out.println(e.getMessage());
> e.printStackTrace();
> }
> return db;
> }
>
>
> }
>
> CollectionTree.java
> import org.xmldb.api.DatabaseManager;
> import org.xmldb.api.base.Collection;
> import org.xmldb.api.base.Database;
>
> //import org.apache.xindice.client.xmldb.DatabaseImpl;
> //import org.apache.xindice.core.Collection;
> //import org.apache.xindice.core.Database;
>
> public class CollectionTree
> {
> public static Database db = null;
> public static final String
> XINDICEURI="xmldb:xindice://localhost:8080/db/";
> protected static Collection collection;
> static int errorCode = 0;
> static int okCode = 1;
> static int liczbaSpacji = 0;
>
> public static void ileSpacji(int liczba)
> {
> if (liczba>0)
> {
> for (int i=0; i<liczba; i++)
> System.out.print(" ");
> }
> }
>
> public static int treeCreate(Collection kolekcja) throws Exception
> {
>
> int liczbaKolekcji = (int)kolekcja.getChildCollectionCount();
> //int liczbaDokumentow = (int)kolekcja.getDocumentCount();
>
> if (liczbaKolekcji > 0)
> {
> String tablica[] = new String[liczbaKolekcji];
> tablica = kolekcja.listChildCollections();
>
> for (int i=0; i<liczbaKolekcji; i++)
> {
> ileSpacji(liczbaSpacji);
> System.out.println("<"+tablica[i]+">");
> liczbaSpacji++;
> treeCreate(kolekcja.getChildCollection(tablica[i]));
> liczbaSpacji--;
> ileSpacji(liczbaSpacji);
> kolekcja.getClass();
> /*if (liczbaDokumentow > 0)
> {
> String tablicaDok[] = new String[liczbaDokumentow];
> tablicaDok = kolekcja.listDocuments();
> for (int j=0; j<liczbaDokumentow; j++)
> {
> System.out.println("<DOC "+tablicaDok[j]+" /");
> }
> }
> */
> System.out.println("</"+tablica[i]+">");
>
> }
>
> }
> else
> return errorCode;
> return okCode;
> }
> public static void main(String[] args) throws Exception
> {
>
>
>
> try
> {
> DBConnection dbcon = new DBConnection();
> db = dbcon.getDB();
> collection = DatabaseManager.getCollection(XINDICEURI);
>
> }
> catch(Exception e)
> {
> System.err.println("XML:DB Exception occured " +
> e.getMessage());
> e.printStackTrace();
> }
>
>
> if (collection.getChildCollectionCount() > 0)
> treeCreate(collection);
>
> }
>
> }
>
Re: how to get collections tree from xindice
Posted by Marcin Goldyn <Ma...@poczta.onet.pl>.
i know how to get ChildCollections and built collection tree
but also i have to get documents stores in particular collections. There are
methods like getDocumentsCount() and listDocuments() in
org.apache.xindice.core.Collection class but this class isn`t work with
org.xmldb.api.DatabaseManager so i cant register database. Maybe there is
another way to register database using org.apache.xindice.core.Collection
class? or there is another way to listDocumetns and count their number??
DBConnection.java
package praca.app;
import org.xmldb.api.base.Database;
import org.xmldb.api.DatabaseManager;
public final class DBConnection
{
public String addressIP;
public String port;
protected static Database db = null;
Database getDB() throws Exception
{
try
{
db =
(Database)Class.forName("org.apache.xindice.client.xmldb.DatabaseImpl").newInstance();
DatabaseManager.registerDatabase(db);
}
catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
return db;
}
}
CollectionTree.java
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Database;
//import org.apache.xindice.client.xmldb.DatabaseImpl;
//import org.apache.xindice.core.Collection;
//import org.apache.xindice.core.Database;
public class CollectionTree
{
public static Database db = null;
public static final String
XINDICEURI="xmldb:xindice://localhost:8080/db/";
protected static Collection collection;
static int errorCode = 0;
static int okCode = 1;
static int liczbaSpacji = 0;
public static void ileSpacji(int liczba)
{
if (liczba>0)
{
for (int i=0; i<liczba; i++)
System.out.print(" ");
}
}
public static int treeCreate(Collection kolekcja) throws Exception
{
int liczbaKolekcji = (int)kolekcja.getChildCollectionCount();
//int liczbaDokumentow = (int)kolekcja.getDocumentCount();
if (liczbaKolekcji > 0)
{
String tablica[] = new String[liczbaKolekcji];
tablica = kolekcja.listChildCollections();
for (int i=0; i<liczbaKolekcji; i++)
{
ileSpacji(liczbaSpacji);
System.out.println("<"+tablica[i]+">");
liczbaSpacji++;
treeCreate(kolekcja.getChildCollection(tablica[i]));
liczbaSpacji--;
ileSpacji(liczbaSpacji);
kolekcja.getClass();
/*if (liczbaDokumentow > 0)
{
String tablicaDok[] = new String[liczbaDokumentow];
tablicaDok = kolekcja.listDocuments();
for (int j=0; j<liczbaDokumentow; j++)
{
System.out.println("<DOC "+tablicaDok[j]+" /");
}
}
*/
System.out.println("</"+tablica[i]+">");
}
}
else
return errorCode;
return okCode;
}
public static void main(String[] args) throws Exception
{
try
{
DBConnection dbcon = new DBConnection();
db = dbcon.getDB();
collection = DatabaseManager.getCollection(XINDICEURI);
}
catch(Exception e)
{
System.err.println("XML:DB Exception occured " +
e.getMessage());
e.printStackTrace();
}
if (collection.getChildCollectionCount() > 0)
treeCreate(collection);
}
}
Re: how to get collections tree from xindice
Posted by Todd Byrne <by...@cns.montana.edu>.
Can you post in the code that your trying to do this with? I am not 100%
sure what your problem is from your description.
Todd
Marcin Goldyn wrote:
> thx for help
> but i have another problem
>
> there are 2 imports
>
> org.dbxml...
> and org.apache.xindice.... i need to use the second one couse it must
> use have getDocumentCount() and listDocuments() org.dbxml doesn`t have
> this methods but if use the second one i don know how to register
> database because till now i use DatabaseManager.registerDatabase(db) and
> i dont how to register using org.apache.xindice import
> can someone help me??
>
> Marcin Goldyn
Re: how to get collections tree from xindice
Posted by Marcin Goldyn <Ma...@poczta.onet.pl>.
thx for help
but i have another problem
there are 2 imports
org.dbxml...
and org.apache.xindice.... i need to use the second one couse it must use
have getDocumentCount() and listDocuments() org.dbxml doesn`t have this
methods but if use the second one i don know how to register database
because till now i use DatabaseManager.registerDatabase(db) and i dont how
to register using org.apache.xindice import
can someone help me??
Marcin Goldyn
Re: how to get collections tree from xindice
Posted by Todd Byrne <by...@cns.montana.edu>.
You can ask root collection db to list its child collections. Then just
print them out.
Here is a small code example:
public static void printCollections() throws Exception
{
Class c =
Class.forName("org.apache.xindice.client.xmldb.DatabaseImpl");
Database database = (Database)c.newInstance();
DatabaseManager.registerDatabase(database);
Collection col = DatabaseManager.getCollection(
"xmldb:xindice://localhost:8080/db");
Stack s = new Stack();
s.push(col);
while(!s.empty())
{
Collection current = (Collection)s.pop();
System.err.println(current.getName());
// list the collections..
String subCollections[] = col.listChildCollections();
for (int i = 0; i < subCollections.length; i++)
{
Collection child = current.getChildCollection(subCollections[i]);
// some of the sub meta collections where null on my setup.
if(child != null)
{
s.push(child);
}
}
}
}
Todd
Marcin Goldyn wrote:
> is there any possibility to get Collections tree from Xindice database??
>
> Marcin Goldyn
how to get collections tree from xindice
Posted by Marcin Goldyn <Ma...@poczta.onet.pl>.
is there any possibility to get Collections tree from Xindice database??
Marcin Goldyn