See: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13746
You can build a version without this bug through a quick hack
to org.apache.xindice.xml.dom.DocumentImpl. Comment
out these 2 lines:
importNamespaces(importedNode, clone);
and
importNamespaces(importedNode, result);
and rebuild.
I have not submitted this as a patch since it is not
a complete solution. It only solves the problem
for a limited set of uses cases (e.g. complete
solution if not using namespaces, and likely a
solution for many cases where you use namespaces,
but may not be correct for all uses of namespaces).
See the bug for a more complete explaination.
This hack will leave the src:key attribute, for example, intact and correct.
-Terry
jcplerm wrote:
I managed to get rid of those "xmlns:src" attributes by modifying the method "expandSource" of classorg.apache.xindice.xml.dom.ElementImpl.java by removing the body as in:
public void expandSource() {}Then I re-built Xindice.Now the result from the database is clean, but the root element of each document contained in the result set no longer has the "src:key" attribute:It's easy to see this is not the right solution... Under certain circumstances the "src:key" attribute is relevant.How can I get rid of the "xmlns:src" in all non-root elements of documents in a result set from a Xindice 1.1b2 server(but, again, keeping them in the root elements)?Thanks,jlerm----- Original Message -----From: jcplermSent: Saturday, August 02, 2003 10:12 PMSubject: 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=""http://xml.apache.org/xindice/Query%22%3EAK%3C/type">http://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=""http://xml.apache.org/xindice/Query%22%3EA%3C/elem4">http://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=""http://xml.apache.org/xindice/Query%22%3ED%3C/elem4">http://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();
}Any ideas?Thanks,jlerm
