Skip to content

Commit

Permalink
xml fix REPORT
Browse files Browse the repository at this point in the history
  • Loading branch information
lennart-k committed Jan 4, 2025
1 parent a304714 commit 3a05671
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/xml/derive/src/xml_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ impl Enum {
}
Event::Comment(_) => { /* ignore */ }
Event::Decl(_) => {
return Err(::rustical_xml::XmlDeError::UnsupportedEvent("Declaration"));
/* ignore */
// return Err(::rustical_xml::XmlDeError::UnsupportedEvent("Declaration"));
}
Event::PI(_) => {
return Err(::rustical_xml::XmlDeError::UnsupportedEvent("Processing instruction"));
Expand Down
30 changes: 30 additions & 0 deletions crates/xml/tests/de_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,33 @@ fn test_xml_values() {
}
);
}

#[test]
fn test_struct_xml_decl() {
#[derive(Debug, XmlDeserialize, XmlRootTag, PartialEq)]
#[xml(root = b"document")]
struct Document {
child: Child,
}

#[derive(Debug, XmlDeserialize, PartialEq, Default)]
struct Child {
#[xml(ty = "text")]
text: String,
}

let doc = Document::parse_str(
r#"
<?xml version="1.0" encoding="utf-8"?>
<document><child>Hello!</child></document>"#,
)
.unwrap();
assert_eq!(
doc,
Document {
child: Child {
text: "Hello!".to_owned()
}
}
);
}

0 comments on commit 3a05671

Please sign in to comment.