From 9c561014f3c4278c0991290c898713f8e9c928e8 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Thu, 3 Apr 2025 03:09:35 +0100 Subject: feat: xml logging --- src/xml/mod.rs | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'src/xml/mod.rs') diff --git a/src/xml/mod.rs b/src/xml/mod.rs index 3f7dc79..b0d9056 100644 --- a/src/xml/mod.rs +++ b/src/xml/mod.rs @@ -66,16 +66,16 @@ impl<'s> QName<'s> { } } -impl<'s> ToString for QName<'s> { - fn to_string(&self) -> String { - match self { - QName::PrefixedName(prefixed_name) => { - format!("{}:{}", **prefixed_name.prefix, **prefixed_name.local_part) - } - QName::UnprefixedName(unprefixed_name) => unprefixed_name.to_string(), - } - } -} +// impl<'s> ToString for QName<'s> { +// fn to_string(&self) -> String { +// match self { +// QName::PrefixedName(prefixed_name) => { +// format!("{}:{}", **prefixed_name.prefix, **prefixed_name.local_part) +// } +// QName::UnprefixedName(unprefixed_name) => unprefixed_name.to_string(), +// } +// } +// } /// [8] PrefixedName ::= Prefix ':' LocalPart #[derive(Clone, Debug, PartialEq, Eq)] @@ -123,7 +123,12 @@ impl<'s> Deref for LocalPart<'s> { // xml spec /// [1] document ::= prolog element Misc* -pub type Document<'s> = (Prolog<'s>, Element<'s>, Vec>); +#[derive(Debug)] +pub struct Document<'s> { + prolog: Prolog<'s>, + element: Element<'s>, + miscs: Vec>, +} /// [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */ #[repr(transparent)] @@ -380,11 +385,12 @@ impl<'s> Deref for CData<'s> { pub struct CDEnd; /// [22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)? -pub type Prolog<'s> = ( - Option>, - Vec>, - Option<(DoctypeDecl<'s>, Vec>)>, -); +#[derive(Debug)] +pub struct Prolog<'s> { + pub(crate) xml_decl: Option>, + pub(crate) miscs: Vec>, + pub(crate) doctype_decl: Option<(DoctypeDecl<'s>, Vec>)>, +} /// [23] XMLDecl ::= '' #[derive(Debug)] @@ -456,7 +462,8 @@ pub enum IntSubsetDeclaration<'s> { } /// from [16] intSubset ::= (markupdecl | PEReference | S)* /// [28b] intSubset ::= (markupdecl | DeclSep)* -pub type IntSubset<'s> = Vec>; +#[derive(Debug)] +pub struct IntSubset<'s>(Vec>); /// [29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment #[derive(Debug)] @@ -481,7 +488,7 @@ pub enum ExtSubsetDeclaration<'s> { DeclSep(DeclSep<'s>), } /// [31] extSubsetDecl ::= ( markupdecl | conditionalSect | DeclSep)* -type ExtSubsetDecl<'s> = Vec>; +pub struct ExtSubsetDecl<'s>(Vec>); /// [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"')) #[derive(Debug, Clone)] -- cgit