@@ -140,12 +140,24 @@ pub enum Error {
140
140
///
141
141
/// [`encoding`]: index.html#encoding
142
142
NonDecodable ( Option < Utf8Error > ) ,
143
- /// `Event::BytesDecl` must start with *version* attribute. Contains the attribute
144
- /// that was found or `None` if an xml declaration doesn't contain attributes.
143
+ /// A `version` attribute was not found in an XML declaration or is not the
144
+ /// first attribute.
145
+ ///
146
+ /// According to the [specification], the XML declaration (`<?xml ?>`) MUST contain
147
+ /// a `version` attribute and it MUST be the first attribute. This error indicates,
148
+ /// that the declaration does not contain attributes at all (if contains `None`)
149
+ /// or either `version` attribute is not present or not the first attribute in
150
+ /// the declaration. In the last case in contains the name of found attribute.
151
+ ///
152
+ /// [specification]: https://www.w3.org/TR/xml11/#sec-prolog-dtd
145
153
XmlDeclWithoutVersion ( Option < String > ) ,
146
- /// Empty `Event::DocType`. `<!doctype foo>` is correct but `<!doctype > is not.
154
+ /// A document type definition (DTD) does not contain a name of a root element.
155
+ ///
156
+ /// According to the [specification], document type definition (`<!doctype foo>`)
157
+ /// MUST contain a name which defines a document type. If that name is missed,
158
+ /// this error is returned.
147
159
///
148
- /// See < https://www.w3.org/TR/xml11/#NT-doctypedecl>
160
+ /// [specification]: https://www.w3.org/TR/xml11/#NT-doctypedecl
149
161
EmptyDocType ,
150
162
/// Attribute parsing error
151
163
InvalidAttr ( AttrError ) ,
@@ -246,12 +258,16 @@ impl fmt::Display for Error {
246
258
Error :: IllFormed ( e) => write ! ( f, "ill-formed document: {}" , e) ,
247
259
Error :: NonDecodable ( None ) => write ! ( f, "Malformed input, decoding impossible" ) ,
248
260
Error :: NonDecodable ( Some ( e) ) => write ! ( f, "Malformed UTF-8 input: {}" , e) ,
249
- Error :: XmlDeclWithoutVersion ( e) => write ! (
261
+ Error :: XmlDeclWithoutVersion ( None ) => {
262
+ write ! ( f, "an XML declaration does not contain `version` attribute" )
263
+ }
264
+ Error :: XmlDeclWithoutVersion ( Some ( attr) ) => {
265
+ write ! ( f, "an XML declaration must start with `version` attribute, but in starts with `{}`" , attr)
266
+ }
267
+ Error :: EmptyDocType => write ! (
250
268
f,
251
- "XmlDecl must start with 'version' attribute, found {:?}" ,
252
- e
269
+ "`<!DOCTYPE>` declaration does not contain a name of a document type"
253
270
) ,
254
- Error :: EmptyDocType => write ! ( f, "DOCTYPE declaration must not be empty" ) ,
255
271
Error :: InvalidAttr ( e) => write ! ( f, "error while parsing attribute: {}" , e) ,
256
272
Error :: EscapeError ( e) => write ! ( f, "{}" , e) ,
257
273
Error :: UnknownPrefix ( prefix) => {
0 commit comments