1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
use { StrSpan, }; /// An XML token. #[derive(Debug)] pub enum Token<'a> { /// Declaration token. /// /// Example: `<?xml version="1.0"?>` Declaration(StrSpan<'a>, Option<StrSpan<'a>>, Option<StrSpan<'a>>), /// Processing instruction token. /// /// Example: `<?target content?>` ProcessingInstruction(StrSpan<'a>, Option<StrSpan<'a>>), /// The comment token. /// /// Example: `<!-- text -->` Comment(StrSpan<'a>), /// DOCTYPE start token. /// /// Example: `<!DOCTYPE note [` DtdStart(StrSpan<'a>, Option<ExternalId<'a>>), /// Empty DOCTYPE token. /// /// Example: `<!DOCTYPE note>` EmptyDtd(StrSpan<'a>, Option<ExternalId<'a>>), /// ENTITY token. /// /// Can appear only inside the DTD. /// /// Example: `<!ENTITY ns_extend "http://test.com">` EntityDeclaration(StrSpan<'a>, EntityDefinition<'a>), /// DOCTYPE end token. /// /// Example: `]>` DtdEnd, /// Element start token. /// /// Example: `<elem` ElementStart(StrSpan<'a>), /// Attribute. /// /// Example: `name="value"` Attribute(StrSpan<'a>, StrSpan<'a>), /// Element end token. ElementEnd(ElementEnd<'a>), /// Text token. /// /// Contains text between elements including whitespaces. /// Basically everything between `>` and `<`. /// /// Contains text as is. Use [`TextUnescape`] to unescape it. /// /// Example: `<text>text</text>` /// /// [`TextUnescape`]: struct.TextUnescape.html Text(StrSpan<'a>), /// Whitespaces token. /// /// The same as `Text` token, but contains only spaces. /// /// Spaces can be encoded like ` `. Whitespaces(StrSpan<'a>), /// CDATA token. /// /// Example: `<![CDATA[text]]>` Cdata(StrSpan<'a>), } /// `ElementEnd` token. #[derive(Debug, PartialEq, Clone, Copy)] pub enum ElementEnd<'a> { /// Indicates `>` Open, /// Indicates `</name>` Close(StrSpan<'a>), /// Indicates `/>` Empty, } /// Representation of the [ExternalID](https://www.w3.org/TR/xml/#NT-ExternalID) value. #[allow(missing_docs)] #[derive(Debug)] pub enum ExternalId<'a> { System(StrSpan<'a>), Public(StrSpan<'a>, StrSpan<'a>), } /// Representation of the [EntityDef](https://www.w3.org/TR/xml/#NT-EntityDef) value. #[allow(missing_docs)] #[derive(Debug)] pub enum EntityDefinition<'a> { EntityValue(StrSpan<'a>), ExternalId(ExternalId<'a>), }