Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Defaulting to UTF-8 in StartDocumentEventImpl#getCharacterEncodingScheme() without XML-Declaration #13

Open
ghost opened this issue Sep 20, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Sep 20, 2018

A org.codehaus.stax2.ri.evt.StartDocumentEventImpl instance is constructed from the values in a XMLStreamReader instance.

The member variable mEncodingScheme is set from the reader-function #getCharacterEncodingScheme(). JavaDoc of that function:

Returns the character encoding declared on the xml declaration Returns null if none was declared

If there is no xml declaration in the document, mEncodingScheme will be null. In XML 1.0 a xml declaration SHOULD be present, but is not required.

The JavaDoc of javax.xml.stream.events.StartDocument, the interface which is implemented defines the return value of the #getCharacterEncodingScheme()-function as follows:

the character encoding, defaults to "UTF-8"

org.codehaus.stax2.ri.evt.StartDocumentEventImpl#getCharacterEncodingScheme() returns the memberVariable mEncodingScheme, which is null when the XML has no xml declaration. I would expect the default value UTF-8.

@cowtowncoder
Copy link
Member

I guess that would make sense, given there is also method encodingSet() allows for determining whether encoding was indicated by XML declaration. Then again, parsers may (actually even need to) detect encoding from source if encoding declaration is missing.

I wish Stax specification was bit more prescriptive, as javadoc wording is still quite vague.

Anyway: I will think about this, and if changed as suggested should probably go in 4.2 as it is behavior change but minor one (could be argued it is a bug, to include in patch too but I prefer minor version).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant