use super::Attribute;
use crate::xml::dom::storage::{Native, Storage};
#[derive(Clone)]
pub enum NodeKind<S: Storage = Native> {
Document,
Element {
name: S::Text,
prefix: Option<S::Text>,
namespace: Option<S::Text>,
attributes: S::Values<Attribute<S>>,
},
Text {
content: S::Text,
},
CData {
content: S::Text,
},
Comment {
content: S::Text,
},
ProcessingInstruction {
target: S::Text,
data: Option<S::Text>,
},
EntityRef {
name: S::Text,
value: Option<S::Text>,
},
DocumentType {
name: S::Text,
system_id: Option<S::Text>,
public_id: Option<S::Text>,
internal_subset: Option<S::Text>,
},
}
impl<S: Storage> std::fmt::Debug for NodeKind<S> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Document => f.write_str("Document"),
Self::Element {
name,
prefix,
namespace,
attributes,
} => f
.debug_struct("Element")
.field("name", name)
.field("prefix", prefix)
.field("namespace", namespace)
.field("attributes", &&attributes[..])
.finish(),
Self::Text { content } => f.debug_struct("Text").field("content", content).finish(),
Self::CData { content } => f.debug_struct("CData").field("content", content).finish(),
Self::Comment { content } => {
f.debug_struct("Comment").field("content", content).finish()
}
Self::ProcessingInstruction { target, data } => f
.debug_struct("ProcessingInstruction")
.field("target", target)
.field("data", data)
.finish(),
Self::EntityRef { name, value } => f
.debug_struct("EntityRef")
.field("name", name)
.field("value", value)
.finish(),
Self::DocumentType {
name,
system_id,
public_id,
internal_subset,
} => f
.debug_struct("DocumentType")
.field("name", name)
.field("system_id", system_id)
.field("public_id", public_id)
.field("internal_subset", internal_subset)
.finish(),
}
}
}