#[non_exhaustive]pub enum Error {
Show 39 variants
InvalidXmlPrefixUri(TextPos),
UnexpectedXmlUri(TextPos),
UnexpectedXmlnsUri(TextPos),
InvalidElementNamePrefix(TextPos),
DuplicatedNamespace(String, TextPos),
UnknownNamespace(String, TextPos),
UnexpectedCloseTag {
expected: String,
actual: String,
pos: TextPos,
},
UnknownEntityReference(String, TextPos),
MalformedEntityReference(TextPos),
DuplicatedAttribute(String, TextPos),
NoRootNode,
UnclosedRootNode,
UnexpectedDeclaration(TextPos),
DtdDetected,
NodesLimitReached,
AttributesLimitReached,
NamespacesLimitReached,
InvalidName(TextPos),
NonXmlChar(char, TextPos),
InvalidChar {
expected: u8,
actual: u8,
pos: TextPos,
},
ExpectedChar {
expected: &'static str,
actual: u8,
pos: TextPos,
},
InvalidString(&'static str, TextPos),
InvalidComment(TextPos),
InvalidCharacterData(TextPos),
UnknownToken(TextPos),
UnexpectedEndOfStream,
InvalidCharacterReference(TextPos),
InvalidPiTarget(TextPos),
PiWithoutWhitespace(TextPos),
InvalidXmlDeclaration(&'static str, TextPos),
InvalidQName(TextPos),
EmptyPrefixedNamespace(String, TextPos),
XmlnsPrefixDeclared(TextPos),
DuplicatedNamespaceDeclaration(String, TextPos),
PrefixedXmlnsAttribute(String, TextPos),
DepthLimitReached,
UnsupportedEncoding(String),
EncodingMismatch {
found: &'static str,
declared: String,
},
InvalidEncodedBytes {
encoding: &'static str,
pos: TextPos,
},
}Expand description
Why a text is not a document the reader accepts.
The variants before Error::InvalidCharacterReference are reported for the same
documents, at the same positions and with the same messages as the roxmltree crate
(version 0.21, with document type declarations refused) reports them. The variants
from Error::InvalidCharacterReference on are for documents that roxmltree
accepts although they are not well-formed (XML 1.0) or not namespace-well-formed
(Namespaces in XML 1.0), and for the limits that it does not have; the crate
documentation lists them.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidXmlPrefixUri(TextPos)
xmlns:xml declares a namespace other than
http://www.w3.org/XML/1998/namespace.
UnexpectedXmlUri(TextPos)
The http://www.w3.org/XML/1998/namespace namespace is declared for a prefix
other than xml, or as the default namespace.
UnexpectedXmlnsUri(TextPos)
The http://www.w3.org/2000/xmlns/ namespace is declared.
InvalidElementNamePrefix(TextPos)
An element name with the xmlns prefix.
DuplicatedNamespace(String, TextPos)
The same prefix is declared twice on an element.
UnknownNamespace(String, TextPos)
An element or attribute name whose prefix is not declared (the prefix).
UnexpectedCloseTag
An end tag that does not match the open element.
Fields
UnknownEntityReference(String, TextPos)
A reference to an entity other than the five predefined ones (its name).
MalformedEntityReference(TextPos)
An & that does not start a well-formed reference to an XML character.
DuplicatedAttribute(String, TextPos)
Two attributes of an element with the same expanded name (the local name).
NoRootNode
No element.
UnclosedRootNode
The text ends before the document element is closed.
UnexpectedDeclaration(TextPos)
An XML declaration elsewhere than at the start of the text.
DtdDetected
A document type declaration: refused, because its entities and attribute defaults could change the document.
NodesLimitReached
More nodes than crate::Limits::nodes.
AttributesLimitReached
More attributes than crate::Limits::attributes.
NamespacesLimitReached
More distinct namespace declarations than crate::Limits::namespaces.
InvalidName(TextPos)
A name that is not a name.
NonXmlChar(char, TextPos)
A character that XML does not allow.
InvalidChar
A byte other than the one expected.
ExpectedChar
A byte other than one of a class expected (described in words).
InvalidString(&'static str, TextPos)
The string expected is missing.
InvalidComment(TextPos)
A comment that contains -- or ends with - (the position of the comment).
InvalidCharacterData(TextPos)
]]> in character data (the position of the end of the text).
UnknownToken(TextPos)
Something that is not markup where markup is expected.
UnexpectedEndOfStream
The text ends in the middle of markup.
InvalidCharacterReference(TextPos)
A character reference to a code point that is not a Unicode scalar value (a
surrogate or a number above 0x10FFFF).
InvalidPiTarget(TextPos)
A processing instruction target that is xml in any case or contains :.
PiWithoutWhitespace(TextPos)
A processing instruction without whitespace between its target and its data.
InvalidXmlDeclaration(&'static str, TextPos)
An XML declaration with a pseudo-attribute that is not version, encoding or
standalone as written, or with an invalid value (the reason).
InvalidQName(TextPos)
A name that starts with :, which is not a qualified name.
EmptyPrefixedNamespace(String, TextPos)
A prefix declared with an empty namespace name (the prefix).
XmlnsPrefixDeclared(TextPos)
A declaration of the xmlns prefix.
DuplicatedNamespaceDeclaration(String, TextPos)
The default namespace (xmlns) or the xml prefix (xmlns:xml) declared twice
on an element (the attribute name).
PrefixedXmlnsAttribute(String, TextPos)
An attribute whose local name is xmlns and which has a prefix (its name).
DepthLimitReached
Elements nested deeper than crate::Limits::depth.
UnsupportedEncoding(String)
A document in an encoding that decode does not read: the name
its XML declaration gives, or UCS-4 or EBCDIC for a document whose first bytes
are in one of those.
EncodingMismatch
The first bytes of a document (a byte order mark, or <? in UTF-16) and its XML
declaration name different encodings.
Fields
InvalidEncodedBytes
Bytes that are not a character in the encoding of the document.
Implementations§
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()