incubator-odf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashok Hariharan <>
Subject Bug in getNamespaceURI() implementation of OdfFileDom
Date Tue, 31 Jan 2012 11:15:25 GMT
The current implementation of getNamespaceURI() in OdfFileDom looks like this :

	public String getNamespaceURI(String prefix) {
		String nsURI = null;
		nsURI = mUriByPrefix.get(prefix);
		if (nsURI == null) {
			nsURI = XMLConstants.NULL_NS_URI;
		return nsURI;

However this is incomplete -- since there is also support for
duplicate NS prefixes in OdfFileDom .e.g , you look at getPrefixes() :

	public Iterator<String> getPrefixes(String namespaceURI) {
		Set<String> prefixes = mDuplicatePrefixesByUri.get(namespaceURI);
		if (prefixes == null) {
			prefixes = new HashSet<String>();
			mDuplicatePrefixesByUri.put(namespaceURI, prefixes);
		return prefixes.iterator();

So if you pass a duplicate prefix to getNamespaceURI() it doesnt
return anything -- which means any XPath queries done using the XPath
context provided by OdfFileDom also fail - so I have to end up using a
custom Namespacecontext ...which kind of defeats the purpose.

E.g. this is RDF metadata as recorded by OpenOffice 3.3 , OOo uses
duplicate namespace prefixes to record custom RDF triples. I cannot
query it with any of these prefixes, nor can I use a fixed NS prefix
to query ... it always fails at getNamespaceURI()

<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="">
 <rdf:Description rdf:about="../content.xml#id1535901849">

I could be able to submit a patch for getNamespaceURI(), if I have
indeed identified a problem --


View raw message