Validator works for start

This commit is contained in:
2025-04-07 14:31:56 +00:00
parent 50539f6d03
commit 2e08be4b75
16 changed files with 108 additions and 82 deletions

View File

@@ -3,12 +3,12 @@ use crate::*;
/// Represents the text content within an XML element
#[derive(Clone, Debug)]
pub struct TextContent {
element: Box<schema::XsElement>,
element: schema::XsElement,
buffer: String,
}
impl TextContent {
pub fn new(element: Box<schema::XsElement>) -> Self {
pub fn new(element: schema::XsElement) -> Self {
Self {
element,
buffer: String::new(),
@@ -16,21 +16,21 @@ impl TextContent {
}
/// Create a new TextContent with the given initial buffer
pub fn with_buffer(element: Box<schema::XsElement>, buffer: String) -> Self {
pub fn with_buffer(element: schema::XsElement, buffer: String) -> Self {
Self {
element,
buffer,
}
}
pub fn append(&self, c: char) -> Vec<Box<Token>> {
pub fn append(&self, c: char) -> Vec<Token> {
if c == '<' {
vec![Box::new(Token::ElementCloseStart(ElementCloseStart::new(Box::new((*self.element).clone()))))]
vec![Token::ElementCloseStart(ElementCloseStart::new(self.element.clone()))]
} else {
vec![Box::new(Token::TextContent(TextContent::with_buffer(
Box::new((*self.element).clone()),
vec![Token::TextContent(TextContent::with_buffer(
self.element.clone(),
self.buffer.clone() + &c.to_string(),
)))]
))]
}
}
}