DOMStreamReader does not implement isWhitespace correctly
---------------------------------------------------------
Key: XFIRE-1072
URL: http://jira.codehaus.org/browse/XFIRE-1072
Project: XFire
Issue Type: Bug
Components: Core
Affects Versions: 1.2.6
Environment: Windows XP, Sun JVM 1.4.2
Reporter: pmarsteau
Assignee: Dan Diephouse
The DOMStreamReader implementation of isWhitespace seems incorrect.
If you use a DepthXMLStreamReader wrapping a W3CDOMStreamReader, and invoke
nextTag() after <tag>, the method will fail with an IllegalStateException
stating that we are receiving CHARACTER data, instead of either START_ELEMENT
or END_ELEMENT.
As per XMLStreamReader spec :
- nextTag must skip any insignificant events (COMMENT and
PROCESSING_INSTRUCTION) until a START_ELEMENT or END_ELEMENT is reached.
- isWhitespace must return true if the cursor points to a character data event
that consists of all whitespace
The DepthXMLStreamReader is correclty implementing the specification, for
nextTag, and delegates the implementation of isWhitespace to the wrapped
XMLStreamReader (here a W3CDOMStreamReader extending DOMStreamReader):
int eventType;
for(eventType = next(); eventType == 4 && isWhiteSpace() || eventType == 12 &&
isWhiteSpace() || eventType == 6 || eventType == 3 || eventType == 5; eventType
= next());
if(eventType != 1 && eventType != 2)
throw new XMLStreamException("expected start or end tag",
getLocation());
else
return eventType;
"
However, the DOMStreamReader implements the isWhitespace as follows:
return (currentEvent == SPACE);
this is only half way correct and should read
if (currentEvent == CHARACTERS || currentEvent == CDATA)
{
return getText().trim().length() == 0;
}
else
{
return (currentEvent == SPACE);
}
I am using XFire core 1.2.6 and did not checked in the latest head if this
issue was already found/fixed.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email