Use check_no_children!() where it makes sense.

This commit is contained in:
Emmanuel Gil Peyrot 2018-05-14 16:33:47 +02:00
commit 3d495ccf41
6 changed files with 13 additions and 37 deletions

View file

@ -267,15 +267,11 @@ impl TryFrom<Element> for Presence {
return Err(Error::ParseError("More than one show element in a presence."));
}
check_no_attributes!(elem, "show");
for _ in elem.children() {
return Err(Error::ParseError("Unknown child in show element."));
}
check_no_children!(elem, "show");
show = Some(Show::from_str(elem.text().as_ref())?);
} else if elem.is("status", ns::DEFAULT_NS) {
check_no_unknown_attributes!(elem, "status", ["xml:lang"]);
for _ in elem.children() {
return Err(Error::ParseError("Unknown child in status element."));
}
check_no_children!(elem, "status");
let lang = get_attr!(elem, "xml:lang", default);
if presence.statuses.insert(lang, elem.text()).is_some() {
return Err(Error::ParseError("Status element present twice for the same xml:lang."));
@ -284,10 +280,8 @@ impl TryFrom<Element> for Presence {
if priority.is_some() {
return Err(Error::ParseError("More than one priority element in a presence."));
}
check_no_attributes!(elem, "status");
for _ in elem.children() {
return Err(Error::ParseError("Unknown child in priority element."));
}
check_no_attributes!(elem, "priority");
check_no_children!(elem, "priority");
priority = Some(Priority::from_str(elem.text().as_ref())?);
} else {
presence.payloads.push(elem.clone());