Fix nested elements
This commit is contained in:
@@ -163,6 +163,17 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_invalid_nesting() {
|
||||||
|
let schema_text = std::fs::read_to_string("../../action_schema.xsd").unwrap();
|
||||||
|
let validator = XmlSchemaValidator::new(&schema_text).unwrap();
|
||||||
|
validator.clone().append("<reasoning><reasoning>").expect_err("Should fail because of nested tag");
|
||||||
|
validator.clone().append("<reasoning> <reasoning>").expect_err("Should fail because of nested tag, even with whitespace");
|
||||||
|
validator.clone().append("<reasoning>foo<reasoning>").expect_err("Should fail because of nested tag, even with text");
|
||||||
|
validator.clone().append("<reasoning> foo <reasoning>").expect_err("Should fail because of nested tag, even with text and whitespace");
|
||||||
|
validator.clone().append("<reasoning> foo <reasoning/>").expect_err("Should fail because of nested tag, even with self closing tag");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_stop_self_closing() {
|
fn test_stop_self_closing() {
|
||||||
let schema_text = std::fs::read_to_string("../../action_schema.xsd").unwrap();
|
let schema_text = std::fs::read_to_string("../../action_schema.xsd").unwrap();
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ impl ElementCloseStart {
|
|||||||
element: Arc::clone(&self.element),
|
element: Arc::clone(&self.element),
|
||||||
has_slash: true,
|
has_slash: true,
|
||||||
})]
|
})]
|
||||||
} else {
|
} else if self.has_slash && self.element.name.starts_with(c) {
|
||||||
if self.element.name.starts_with(c) {
|
|
||||||
vec![Token::ElementCloseName(ElementCloseName::new(
|
vec![Token::ElementCloseName(ElementCloseName::new(
|
||||||
Arc::clone(&self.element),
|
Arc::clone(&self.element),
|
||||||
c.to_string(),
|
c.to_string(),
|
||||||
@@ -34,7 +33,6 @@ impl ElementCloseStart {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod element_close_start_tests {
|
mod element_close_start_tests {
|
||||||
|
|||||||
Reference in New Issue
Block a user