Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

StAXStreamBuilder should support SPACE before START_DOCUMENT #101

Closed
trygvis opened this Issue · 1 comment

2 participants

@trygvis

This document:

<?xml version="1.0"?>
<root>
    ..
</root>

will generate the event sequence:

START_DOCUMENT
SPACE
START_ELEMENT
...

which is legal. If SPACE would have been CHARACTERS it would have been illegal, but whitespace is acceptable.

https://github.com/hunterhacker/jdom/blob/master/core/src/java/org/jdom2/input/StAXStreamBuilder.java#L162

It seems that the Event version has the same issue, but fails with a null pointer exception.

@rolfl
Collaborator

Hi Trygve.

I am not claiming that you are wrong, because it seems logical that SPACE is valid outside the root element. What I don't have though is an example of where the SPACE is called.

The StAX documentation is pretty bad, and I did most of the work by simply running the code itself. What I have is the tests here:

https://github.com/hunterhacker/jdom/blob/master/test/src/java/org/jdom2/test/cases/input/TestStAXStreamBuilder.java

which parse documents like this one:
https://github.com/hunterhacker/jdom/blob/master/test/src/resources/DOMBuilder/doctype.xml

The above document is a good example of your problem case, I think. It has two 'SPACE' areas outside of the root Element.

So, the above test case works for me for both Event and Stream parsing.

What this means is that my StAX library must be different to yours, and I can't test any changes I make in order to verify them.

What StAX parser are you using...?

When I set the -Djavax.debug=1 and I run the example test case above, I get the following:

JAXP: find factoryId =javax.xml.stream.XMLInputFactory
JAXP: loaded from fallback value: com.sun.xml.internal.stream.XMLInputFactoryImpl
JAXP: created new instance of class com.sun.xml.internal.stream.XMLInputFactoryImpl using ClassLoader: null

So, What StAX parser are you using?

Rolf

@rolfl rolfl referenced this issue from a commit
@rolfl rolfl Fixes #101 - possible problem with some StAX streams supplying SPACE …
…content outside the root element. Not able to reproduce with my StAX libraries, but the fix is 'safe'.
be510b2
@rolfl rolfl closed this issue from a commit
@rolfl rolfl Fixes #101 - possible problem with some StAX streams supplying SPACE …
…content outside the root element. Not able to reproduce with my StAX libraries, but the fix is 'safe'.
b00258b
@rolfl rolfl closed this in b00258b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.