Issue Details (XML | Word | Printable)

Key: WSTX-56
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Tatu Saloranta
Reporter: Sam Pullara
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Woodstox

A filtered xml event stream can sometimes still return something that should be filtered out

Created: 07/May/06 04:55 PM   Updated: 22/Jun/06 12:05 AM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. Java Source File WoodstoxTest.java (1 kB)
2. Java Source File WoodstoxTest.java (1 kB)

Environment: Current Wstx, Mac, 1.5/1.6

Testcase included: yes


 Description  « Hide
// Parse the data, filtering out the start elements
XMLInputFactory xmlif = XMLInputFactory.newInstance();
FileReader fr = new FileReader("src-data/foundbugs.xml");
XMLEventReader xmler = xmlif.createXMLEventReader(fr);
EventFilter filter = new EventFilter() {
public boolean accept(XMLEvent event) { return event.isStartElement(); }
};
XMLEventReader xmlfer = xmlif.createFilteredReader(xmler, filter);
while (xmlfer.peek() != null) {

At this point the event that is peeked() should always be a StartElement or null. I've found this not to be true and have gotten back peeks() that are Characters, etc.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Sam Pullara added a comment - 07/May/06 05:02 PM
Update so that it works with the RI

Tatu Saloranta added a comment - 08/May/06 04:13 PM
Thanks! It's known that the filtered event reader has plenty of problems (some of which may be fundamental problems with the concept itself – should START/END_DOCUMENT events ever be suppressed; and if latter is, should 'null' be returned instead of it at the end: also, implementing hasNext() is quite complicated). However, specific problems like this one should definitely be fixed; I can look into both Woodstox and Ref. Impl. to resolve problem in both.

Tatu Saloranta added a comment - 10/May/06 01:28 AM
Added unit test (within StaxTest, part of stax ref. impl. distribution), and fixed for Woodstox. Ref. impl. does not seem to have the same bug.
Will be included in 2.9.4 release.

Tatu Saloranta added a comment - 22/Jun/06 12:05 AM
Included in 3.0rc1 release.