incubator-odf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashok Hariharan <as...@parliaments.info>
Subject Re: test and patch : getNamespaceURI() implementation in OdfFileDom
Date Thu, 09 Feb 2012 20:44:21 GMT
Hi Svante --

the line you mention was already there (perhaps an earlier update ) --
if you see my patch
(https://issues.apache.org/jira/secure/attachment/12512926/odffiledom-patch.txt)
:

--- src/main/java/org/odftoolkit/odfdom/pkg/OdfFileDom.java	(revision 1239471)
+++ src/main/java/org/odftoolkit/odfdom/pkg/OdfFileDom.java	(working copy)
@@ -355,8 +355,21 @@
 		String nsURI = null;
 		nsURI = mUriByPrefix.get(prefix);
 		if (nsURI == null) {
-			nsURI = XMLConstants.NULL_NS_URI;
-		}
+                        //look in Duplicate URI prefixes
+                        Set<String> urisWithDuplicatePrefixes =
this.mDuplicatePrefixesByUri.keySet();
+                        for (String aURI : urisWithDuplicatePrefixes) {
+                            Set<String> prefixes =
this.mDuplicatePrefixesByUri.get(aURI);
+                            // check if requested prefix exists in hashset
+                            if (prefixes.contains(prefix)) {
+                                nsURI = aURI;
+                                break;
+                            }
+                        }
+                }
+                //there is a possiblity it still may be null - so we check
+                if (nsURI == null ) {
+                    nsURI = XMLConstants.NULL_NS_URI;
+                }

there is no ... ByUri.put(namespaceURI,prefixes) line in my patch...

Ashok


On Tue, Feb 7, 2012 at 1:39 AM, Svante Schubert
<svante.schubert@gmail.com> wrote:
> I have added my comments to the closed issue
>
> https://issues.apache.org/jira/browse/ODFTOOLKIT-302
>
> It all comes down, that you had a line too much in your patch:
> mDuplicatePrefixesByUri.put(namespaceURI, prefixes);
>
> The put() within a get() context was suspicious, but the method was broken anyway and
I owe you that you found out and provided a patch.
>
> Thanks again,
> Svante
>
> On 02.02.2012 08:34, Ashok Hariharan wrote:
>> Hello there --
>>
>> I am submitting a patched test case "xpathtest-case-patch.txt" and the
>> corresponding odt file used by the test.
>>
>> To simulate the problem --
>>
>> 1) apply the patch xpathtest-case-patch.txt on the ODFDOM source
>> 2) put the XPathTest-duplicate-prefix.odt in odfdom/src/test/resources
>> 3) Run the src/test/java/org/odftoolkit/odfdom/dom/XPathTest.java unit
>> test. It fails.
>> 4) apply the patch odffiledom-patch.txt on OdfFileDom and run the unit
>> test again. It passes.
>>
>> I have added explanatory comments in the patched unit test and the
>> patched getNamespaceURI()
>>
>> thanks,
>>
>> Ashok Hariharan
>

Mime
View raw message