You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by zi...@apache.org on 2004/01/29 05:08:56 UTC
cvs commit: xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal MarshalStreamUtils.java
zieg 2004/01/28 20:08:56
Modified: v2/src/marshal/org/apache/xmlbeans/impl/marshal
MarshalStreamUtils.java
Log:
Ignore DTD and other unknown event types
Revision Changes Path
1.13 +37 -24 xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalStreamUtils.java
Index: MarshalStreamUtils.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalStreamUtils.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- MarshalStreamUtils.java 29 Jan 2004 03:48:28 -0000 1.12
+++ MarshalStreamUtils.java 29 Jan 2004 04:08:56 -0000 1.13
@@ -162,16 +162,22 @@
reader.hasNext();
state = reader.next()) {
switch (state) {
- case XMLStreamReader.END_DOCUMENT:
- throw new XmlRuntimeException("unexpected end of XML");
- case XMLStreamReader.END_ELEMENT:
- return false;
case XMLStreamReader.START_ELEMENT:
return true;
+ case XMLStreamReader.END_ELEMENT:
+ return false;
+ case XMLStreamReader.END_DOCUMENT:
+ throw new XmlRuntimeException("unexpected end of XML");
+
+ case XMLStreamReader.PROCESSING_INSTRUCTION:
case XMLStreamReader.CHARACTERS:
//TODO: what about mixed content models
- case XMLStreamReader.PROCESSING_INSTRUCTION:
case XMLStreamReader.COMMENT:
+ case XMLStreamReader.SPACE:
+ case XMLStreamReader.ENTITY_REFERENCE:
+ case XMLStreamReader.DTD:
+ case XMLStreamReader.NOTATION_DECLARATION:
+ case XMLStreamReader.ENTITY_DECLARATION:
break;
default:
throw new AssertionError("unexpected xml state " + state);
@@ -207,9 +213,9 @@
for (int state = reader.getEventType(); reader.hasNext();
state = reader.next()) {
switch (state) {
- case XMLStreamReader.END_DOCUMENT:
- //should not happen for well-formed xml
- throw new XmlRuntimeException("unexpected end of xml document");
+ case XMLStreamReader.START_ELEMENT:
+ cnt++;
+ break;
case XMLStreamReader.END_ELEMENT:
if (cnt == 0) {
assert reader.hasNext();
@@ -219,9 +225,9 @@
cnt--;
}
break;
- case XMLStreamReader.START_ELEMENT:
- cnt++;
- break;
+ case XMLStreamReader.END_DOCUMENT:
+ //should not happen for well-formed xml
+ throw new XmlRuntimeException("unexpected end of xml document");
default:
break;
}
@@ -267,28 +273,35 @@
for (int state = rdr.getEventType(); rdr.hasNext(); state = rdr.next()) {
switch (state) {
- //these are things we can handle...
+
case XMLStreamReader.START_ELEMENT:
return;
+ case XMLStreamReader.END_ELEMENT:
+ throw new XmlRuntimeException("unexpected end of XML");
- //eventually we'll handle these...
- case XMLStreamReader.ATTRIBUTE:
- throw new AssertionError("NAKED ATTRIBUTE UNIMPLEMENTED");
+ case XMLStreamReader.PROCESSING_INSTRUCTION:
+ break;
case XMLStreamReader.CHARACTERS:
if (rdr.isWhiteSpace()) break;
throw new AssertionError("NAKED CHARDATA UNIMPLEMENTED");
-
- //bad news in the xml stream
+ case XMLStreamReader.COMMENT:
+ case XMLStreamReader.SPACE:
+ case XMLStreamReader.START_DOCUMENT:
+ break;
case XMLStreamReader.END_DOCUMENT:
throw new XmlRuntimeException("unexpected end of XML");
- case XMLStreamReader.END_ELEMENT:
- throw new XmlRuntimeException("unexpected end of XML");
- //skip these and keep going
- case XMLStreamReader.PROCESSING_INSTRUCTION:
- case XMLStreamReader.COMMENT:
- case XMLStreamReader.START_DOCUMENT:
- case XMLStreamReader.SPACE:
+ case XMLStreamReader.ENTITY_REFERENCE:
+ break;
+
+ case XMLStreamReader.ATTRIBUTE:
+ throw new AssertionError("NAKED ATTRIBUTE UNIMPLEMENTED");
+
+ case XMLStreamReader.DTD:
+ case XMLStreamReader.CDATA:
+ case XMLStreamReader.NAMESPACE:
+ case XMLStreamReader.NOTATION_DECLARATION:
+ case XMLStreamReader.ENTITY_DECLARATION:
break;
default:
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org