----- Original Message -----
Sent: Saturday, August 02, 2003 10:12
PM
Subject: How to get rid of namespace?
(Xindice 1.1b2)
I was able to run a query against a collection
using the CollectionImpl class.
I get each and every element in the result set
tagged with a namespace, like:
...
<elem1 id="k2" xmlns:src=""http://xml.apache.org/xindice/Query">http://xml.apache.org/xindice/Query">
<type xmlns:src="">AKhttp://xml.apache.org/xindice/Query">AK</type>
<elem2 xmlns:src=""http://xml.apache.org/xindice/Query">http://xml.apache.org/xindice/Query">
<elem3 id="c" xmlns:src=""http://xml.apache.org/xindice/Query">http://xml.apache.org/xindice/Query">
<elem4 xmlns:src="">Ahttp://xml.apache.org/xindice/Query">A</elem4>
</elem3>
<elem3 id="b" xmlns:src=""http://xml.apache.org/xindice/Query">http://xml.apache.org/xindice/Query">
<elem4 xmlns:src="">Dhttp://xml.apache.org/xindice/Query">D</elem4>
</elem3>
</elem2>
</elem1>
...
I actually made another version of
CollectionImpl.query(), which returns the content from the server without
building a resource set as in:
public String
queryAsString(String name, String queryLang, String query, Hashtable nsMap)
throws XMLDBException {
checkOpen();
try
{
Hashtable params = new
Hashtable();
params.put(RPCDefaultMessage.COLLECTION,
collPath);
params.put(RPCDefaultMessage.TYPE,
queryLang);
params.put(RPCDefaultMessage.NAMESPACES,
nsMap);
params.put(RPCDefaultMessage.QUERY, query);
if (name != null) {
params.put(RPCDefaultMessage.NAME,
name);
}
String result = (String) runRemoteCommand("Query",
params);
return result;
} catch
(Exception e) {
throw FaultCodes.createXMLDBException(FaultCodes.QRY_PROCESSING_ERROR,
"Query error", e);
}
}
I then invoke it like:
String rs=null;
try {
rs =
coll.queryAsString(null,"XPath","/entity",new
Hashtable());
System.out.println("RESULT===>>> " +
rs);
}
catch (XMLDBException e)
{
System.out.println("XMLRPCTest.main(): query() failed: " +
e.getMessage());
e.printStackTrace();
}