pub enum SerializeError {
Io(Error),
InvalidChar {
code_point: u32,
context: &'static str,
},
InvalidComment(String),
InvalidPi {
target: String,
reason: &'static str,
},
UnboundName {
prefix: String,
uri: String,
},
NotSerializable(DomNodeType),
}Expand description
Why a tree could not be written as XML.
Every variant but Io reports content that no
well-formed XML document can hold, so it is reported rather than silently
repaired; repairing names is the job of the code that builds the tree.
use xsd_schema::document::{serialize, SerializeError};
use xsd_schema::navigator::{DomNavigator, RoXmlNavigator};
// An attribute is not a tree, so it cannot be written on its own.
let doc = roxmltree::Document::parse(r#"<a k="v"/>"#)?;
let mut attr = RoXmlNavigator::new(&doc);
attr.move_to_first_child();
attr.move_to_first_attribute();
match serialize::to_string(&attr, &Default::default()) {
Err(SerializeError::NotSerializable(kind)) => println!("refused {kind:?}"),
other => panic!("expected a refusal, got {other:?}"),
}Variants§
Io(Error)
The writer failed.
InvalidChar
A character that the XML 1.0 Char production does not allow, in a
place where no escape can express it either.
context is one of "text", "attribute value", "comment",
"processing instruction" or "name".
InvalidComment(String)
Comment content containing --, or ending in - (XML 1.0 §2.5).
InvalidPi
A processing instruction that XML 1.0 §2.6 does not allow.
Fields
UnboundName
An element or attribute name whose prefix is not bound to its namespace URI in the scope the output establishes, so the written name would not re-parse to the same expanded name.
Fields
NotSerializable(DomNodeType)
An attribute or namespace node was asked to serialize itself. Both are properties of an element, not subtrees, so there is nothing to write.
Trait Implementations§
Source§impl Debug for SerializeError
impl Debug for SerializeError
Source§impl Display for SerializeError
impl Display for SerializeError
Source§impl Error for SerializeError
impl Error for SerializeError
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()