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]
|
||||
fn test_stop_self_closing() {
|
||||
let schema_text = std::fs::read_to_string("../../action_schema.xsd").unwrap();
|
||||
|
||||
@@ -23,8 +23,7 @@ impl ElementCloseStart {
|
||||
element: Arc::clone(&self.element),
|
||||
has_slash: true,
|
||||
})]
|
||||
} else {
|
||||
if self.element.name.starts_with(c) {
|
||||
} else if self.has_slash && self.element.name.starts_with(c) {
|
||||
vec![Token::ElementCloseName(ElementCloseName::new(
|
||||
Arc::clone(&self.element),
|
||||
c.to_string(),
|
||||
@@ -33,7 +32,6 @@ impl ElementCloseStart {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user