import org.apache.xindice.*;
import org.apache.xindice.client.xmldb.*;
import org.apache.xindice.client.xmldb.xmlrpc.*;

import java.io.StringReader;
import java.net.MalformedURLException;
import java.util.Hashtable;
import java.util.Vector;

import javax.xml.parsers.DocumentBuilderFactory;

import org.apache.xindice.client.xmldb.xmlrpc.*;
import org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl;

import org.apache.xindice.client.xmldb.ResourceSetImpl;
import org.apache.xindice.client.xmldb.XindiceCollection;
import org.apache.xindice.client.xmldb.resources.XMLResourceImpl;
import org.apache.xindice.core.FaultCodes;
import org.apache.xindice.server.rpc.RPCDefaultMessage;
import org.apache.xindice.server.rpc.RPCMessageInterface;
import org.apache.xindice.util.SymbolDeserializer;
import org.apache.xindice.xml.TextWriter;

import org.apache.xmlrpc.XmlRpc;
import org.apache.xmlrpc.XmlRpcClient;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import org.xml.sax.InputSource;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.ErrorCodes;
import org.xmldb.api.base.Resource;
import org.xmldb.api.base.ResourceSet;
import org.xmldb.api.base.XMLDBException;
import org.xmldb.api.modules.XMLResource;

public class xmldbtest{

  public static void main(String[] args) throws Exception {
	CollectionImpl compl = null;
	String[] colist =null;
	String keyword = null;
	ResourceSet rs = null;

	XmlRpcClient xClient = new XmlRpcClient("http://localhosts:8080/Xindice");
	Hashtable ht = new Hashtable();
	ht.put("message", "Query");

	String querystr = null;
	
	querystr = "/person/*";
	try
	{
		compl = new CollectionImpl("localhost:8080", "/db/test");
		colist = compl.listResources();
	}
	catch (Exception e){System.out.println(e);}

	try
	{
		rs = compl.query(null, "xpath", querystr, ht);
	}
	catch (Exception e1){System.out.println(e1);}
	
	if(rs == null)
	System.out.println("null rs");


	for(int i=0; i<colist.length; i++)
	{
		System.out.println("\n\r" + colist[i]);
	}
    }
}