incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svanteschub...@apache.org
Subject svn commit: r1310105 - in /incubator/odf/trunk/odfdom/src: main/java/org/odftoolkit/odfdom/pkg/OdfFileDom.java test/java/org/odftoolkit/odfdom/dom/XPathTest.java
Date Thu, 05 Apr 2012 22:11:28 GMT
Author: svanteschubert
Date: Thu Apr  5 22:11:28 2012
New Revision: 1310105

URL: http://svn.apache.org/viewvc?rev=1310105&view=rev
Log:
#ODFTOOLKIT-302# getNamespaceURI() implementation in ODFDOM is not aware of duplicate namespace
prefixes [Developer:ashok.hariharan; Reviewer:svanteschubert]

Modified:
    incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfFileDom.java
    incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/dom/XPathTest.java

Modified: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfFileDom.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfFileDom.java?rev=1310105&r1=1310104&r2=1310105&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfFileDom.java (original)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfFileDom.java Thu
Apr  5 22:11:28 2012
@@ -509,9 +509,11 @@ public class OdfFileDom extends Document
 		Set<String> prefixes = mDuplicatePrefixesByUri.get(namespaceURI);
 		if (prefixes == null) {
 			prefixes = new HashSet<String>();
-			mDuplicatePrefixesByUri.put(namespaceURI, prefixes);
 		}
-		prefixes.add(mPrefixByUri.get(namespaceURI));
+		String givenPrefix = mPrefixByUri.get(namespaceURI);
+		if(givenPrefix != null){
+			prefixes.add(givenPrefix);
+		}
 		return prefixes.iterator();
 	}
 

Modified: incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/dom/XPathTest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/dom/XPathTest.java?rev=1310105&r1=1310104&r2=1310105&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/dom/XPathTest.java (original)
+++ incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/dom/XPathTest.java Thu
Apr  5 22:11:28 2012
@@ -45,7 +45,7 @@ public class XPathTest {
 	private static final String SOURCE_FILE_2 = "XPathTest-foreignPrefix2.odp";
         private static final String SOURCE_FILE_3 = "XPathTest-duplicate-prefix.odt";
 	/**
-	 * 1) The first test document "slideDeckWithTwoSlides.odp" uses the prefix "daisy" instead
of "office" for ODF XML elements.
+	 * 1) The first test document "XPathTest-foreignPrefix.odp" uses the prefix "daisy" instead
of "office" for ODF XML elements.
 	   <daisy:document-content xmlns:daisy="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:style="ur...
 			<daisy:scripts/>
 			<daisy:automatic-styles>
@@ -94,7 +94,7 @@ public class XPathTest {
 			}
 			// There should be no further prefix
 			Assert.assertFalse(prefixes.hasNext());
-
+					
 			Iterator<String> prefixes2 = contentDom.getPrefixes("urn://some-test-odfdom-namespace");
 			prefix = prefixes2.next();
 			Assert.assertTrue(prefix.equals("prefixOne") || prefix.equals("prefixTwo"));
@@ -131,6 +131,10 @@ public class XPathTest {
 			String alienElementValue = (String) xpath.evaluate("//text:p/test", node, XPathConstants.STRING);
 			LOG.log(Level.INFO, "The value of the alien element is {0}, expected is ''good''!", alienElementValue);
 			Assert.assertEquals("good", alienElementValue);
+			
+			// Test if an empty iterator is being returned for a none existing URL
+			Iterator<String> prefixes3 = contentDom.getPrefixes("urn://this-prefix-does-not-exist-in-the-xml");
+			Assert.assertFalse("Not used prefix returned a none-empty iterator!", prefixes3.hasNext());
 		} catch (Exception e) {
 			LOG.log(Level.SEVERE, e.getMessage(), e);
 			Assert.fail(e.toString());



Mime
View raw message