You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by da...@apache.org on 2012/04/18 18:37:38 UTC

svn commit: r1327571 - in /incubator/jena/Jena2/jena/trunk/src: main/java/com/hp/hpl/jena/xmloutput/impl/BaseXMLWriter.java test/java/com/hp/hpl/jena/xmloutput/TestXMLFeatures.java

Author: damian
Date: Wed Apr 18 16:37:38 2012
New Revision: 1327571

URL: http://svn.apache.org/viewvc?rev=1327571&view=rev
Log:
JENA-24 fix: xml writer would bind xml and xmlns namespaces

Modified:
    incubator/jena/Jena2/jena/trunk/src/main/java/com/hp/hpl/jena/xmloutput/impl/BaseXMLWriter.java
    incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/xmloutput/TestXMLFeatures.java

Modified: incubator/jena/Jena2/jena/trunk/src/main/java/com/hp/hpl/jena/xmloutput/impl/BaseXMLWriter.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/jena/trunk/src/main/java/com/hp/hpl/jena/xmloutput/impl/BaseXMLWriter.java?rev=1327571&r1=1327570&r2=1327571&view=diff
==============================================================================
--- incubator/jena/Jena2/jena/trunk/src/main/java/com/hp/hpl/jena/xmloutput/impl/BaseXMLWriter.java (original)
+++ incubator/jena/Jena2/jena/trunk/src/main/java/com/hp/hpl/jena/xmloutput/impl/BaseXMLWriter.java Wed Apr 18 16:37:38 2012
@@ -340,6 +340,9 @@ abstract public class BaseXMLWriter impl
     
     final public String getPrefixFor( String uri )
         {
+            // xml and xmlns namespaces are pre-bound
+            if ("http://www.w3.org/XML/1998/namespace".equals(uri)) return "xml";
+            if ("http://www.w3.org/2000/xmlns/".equals(uri)) return "xmlns";
         Set<String> s = nameSpaces.backward( uri );
         if (s != null && s.size() == 1) return s.iterator().next();
         return null; 

Modified: incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/xmloutput/TestXMLFeatures.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/xmloutput/TestXMLFeatures.java?rev=1327571&r1=1327570&r2=1327571&view=diff
==============================================================================
--- incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/xmloutput/TestXMLFeatures.java (original)
+++ incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/xmloutput/TestXMLFeatures.java Wed Apr 18 16:37:38 2012
@@ -235,7 +235,23 @@ public class TestXMLFeatures extends XML
 		// }
 		// });
 	}
-
+        
+        // JENA-24
+        public void testDisallowedXMLNamespace() throws IOException {
+		// xml and xmlns, if present, must be bound to correct namespaces
+		check(file1, null, Change.setPrefix("j.0", "http://www.w3.org/XML/1998/namespace"));
+                check(file1, null, Change.setPrefix("xml", "http://www.w3.org/XML/1998/namespace"));
+                // Not sure about this case. It's bad, but it ought to round trip
+                //check(file1, null, Change.setPrefix("xml", "http://example.org/#"));
+	}
+        
+        // JENA-24
+        public void testDisallowedXMLNSNamespace() throws IOException {
+		// xml and xmlns, if present, must be bound to correct namespaces
+		check(file1, null, Change.setPrefix("j.0", "http://www.w3.org/2000/xmlns/"));
+                check(file1, null, Change.setPrefix("xmlns", "http://www.w3.org/2000/xmlns/"));
+	}
+        
 	public void testDuplicateNamespace() throws IOException {
 		check(
 				file1,