diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2009-07-07 11:52:12 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2009-07-07 11:52:12 +0000 |
commit | 7e8b44e1c203d4549722e2cc6c40d600f809bce9 (patch) | |
tree | a52cca40033b3e9f6a87ef7b69af9d07e697ea48 /gnu | |
parent | d50d3f0c5bcb967a5bcaa999e1c54c51cd78dcd2 (diff) | |
download | classpath-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.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/xml/stream/XMLStreamWriterImpl.java | 23 |
1 files changed, 19 insertions, 4 deletions
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 } + |