Fix nested elements
This commit is contained in:
@@ -162,6 +162,17 @@ mod tests {
|
|||||||
"Error should mention missing required attribute or invalid continuation");
|
"Error should mention missing required attribute or invalid continuation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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() {
|
||||||
|
|||||||
@@ -23,15 +23,13 @@ impl ElementCloseStart {
|
|||||||
element: Arc::clone(&self.element),
|
element: Arc::clone(&self.element),
|
||||||
has_slash: true,
|
has_slash: true,
|
||||||
})]
|
})]
|
||||||
|
} else if self.has_slash && self.element.name.starts_with(c) {
|
||||||
|
vec![Token::ElementCloseName(ElementCloseName::new(
|
||||||
|
Arc::clone(&self.element),
|
||||||
|
c.to_string(),
|
||||||
|
))]
|
||||||
} else {
|
} else {
|
||||||
if self.element.name.starts_with(c) {
|
vec![]
|
||||||
vec![Token::ElementCloseName(ElementCloseName::new(
|
|
||||||
Arc::clone(&self.element),
|
|
||||||
c.to_string(),
|
|
||||||
))]
|
|
||||||
} else {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user