summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2009-07-07 11:52:12 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2009-07-07 11:52:12 +0000
commit7e8b44e1c203d4549722e2cc6c40d600f809bce9 (patch)
treea52cca40033b3e9f6a87ef7b69af9d07e697ea48
parentd50d3f0c5bcb967a5bcaa999e1c54c51cd78dcd2 (diff)
downloadclasspath-7e8b44e1c203d4549722e2cc6c40d600f809bce9.tar.gz
2009-07-06 Ludovic Claude <ludovic.claude@laposte.net>
PR xml/40653 * gnu/xml/stream/XMLStreamWriterImpl.java: Weaken testing of namespace prefix to match reference implementation and spec.
-rw-r--r--ChangeLog7
-rw-r--r--gnu/xml/stream/XMLStreamWriterImpl.java23
2 files changed, 26 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 77a6620ab..6326ce050 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-07-06 Ludovic Claude <ludovic.claude@laposte.net>
+
+ PR xml/40653:
+ * gnu/xml/stream/XMLStreamWriterImpl.java:
+ Weaken testing of namespace prefix to match
+ reference implementation and spec.
+
2009-07-07 Andrew John Hughes <ahughes@redhat.com>
PR classpath/40630
diff --git a/gnu/xml/stream/XMLStreamWriterImpl.java b/gnu/xml/stream/XMLStreamWriterImpl.java
index 4be9992a7..1549420c9 100644
--- a/gnu/xml/stream/XMLStreamWriterImpl.java
+++ b/gnu/xml/stream/XMLStreamWriterImpl.java
@@ -242,7 +242,7 @@ public class XMLStreamWriterImpl
{
if (namespaceURI != null && !isURI(namespaceURI))
throw new IllegalArgumentException("illegal URI: " + namespaceURI);
- if (prefix != null && !isNCName(prefix))
+ if (prefix != null && !isPrefix(prefix))
throw new IllegalArgumentException("illegal NCName: " + prefix);
if (!isNCName(localName))
throw new IllegalArgumentException("illegal NCName: " + localName);
@@ -394,7 +394,7 @@ public class XMLStreamWriterImpl
{
if (namespaceURI != null && !isURI(namespaceURI))
throw new IllegalArgumentException("illegal URI: " + namespaceURI);
- if (prefix != null && !isNCName(prefix))
+ if (prefix != null && !isPrefix(prefix))
throw new IllegalArgumentException("illegal NCName: " + prefix);
if (!isNCName(localName))
throw new IllegalArgumentException("illegal NCName: " + localName);
@@ -490,13 +490,18 @@ public class XMLStreamWriterImpl
public void writeNamespace(String prefix, String namespaceURI)
throws XMLStreamException
{
+ if (prefix == null || "".equals(prefix) || "xmlns".equals(prefix))
+ {
+ writeDefaultNamespace(namespaceURI);
+ return;
+ }
if (!inStartElement)
throw new IllegalStateException();
try
{
if (!isURI(namespaceURI))
throw new IllegalArgumentException("illegal URI: " + namespaceURI);
- if (!isNCName(prefix))
+ if (!isPrefix(prefix))
throw new IllegalArgumentException("illegal NCName: " + prefix);
}
catch (IOException e)
@@ -790,7 +795,7 @@ public class XMLStreamWriterImpl
{
if (!isURI(uri))
throw new IllegalArgumentException("illegal URI: " + uri);
- if (!isNCName(prefix))
+ if (!isPrefix(prefix))
throw new IllegalArgumentException("illegal NCName: " + prefix);
}
catch (IOException e)
@@ -938,6 +943,15 @@ public class XMLStreamWriterImpl
return true;
}
+ private boolean isPrefix(String text)
+ throws IOException
+ {
+ if (XMLConstants.DEFAULT_NS_PREFIX.equals(text)) {
+ return true;
+ }
+ return isNCName(text);
+ }
+
private boolean isNCName(String text)
throws IOException
{
@@ -1001,3 +1015,4 @@ public class XMLStreamWriterImpl
}
+