aboutsummaryrefslogtreecommitdiffstats
path: root/src/xml/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/xml/mod.rs')
-rw-r--r--src/xml/mod.rs44
1 files changed, 41 insertions, 3 deletions
diff --git a/src/xml/mod.rs b/src/xml/mod.rs
index 3150df0..43f3027 100644
--- a/src/xml/mod.rs
+++ b/src/xml/mod.rs
@@ -389,9 +389,9 @@ pub type Prolog<'s> = (
/// [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
#[derive(Debug)]
pub struct XMLDecl<'s> {
- version_info: VersionInfo,
- encoding_decl: Option<EncodingDecl<'s>>,
- sd_decl: Option<SDDecl>,
+ pub(crate) version_info: VersionInfo,
+ pub(crate) encoding_decl: Option<EncodingDecl<'s>>,
+ pub(crate) sd_decl: Option<SDDecl>,
}
/// [24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
@@ -401,6 +401,17 @@ pub enum VersionInfo {
DoubleQuoted(VersionNum),
}
+impl Deref for VersionInfo {
+ type Target = VersionNum;
+
+ fn deref(&self) -> &Self::Target {
+ match self {
+ VersionInfo::SingleQuoted(version_num) => version_num,
+ VersionInfo::DoubleQuoted(version_num) => version_num,
+ }
+ }
+}
+
/// [25] Eq ::= S? '=' S?
#[derive(Clone)]
pub struct Eq;
@@ -479,6 +490,17 @@ pub enum SDDecl {
DoubleQuoted(bool),
}
+impl Deref for SDDecl {
+ type Target = bool;
+
+ fn deref(&self) -> &Self::Target {
+ match self {
+ SDDecl::SingleQuoted(b) => b,
+ SDDecl::DoubleQuoted(b) => b,
+ }
+ }
+}
+
// (Productions 33 through 38 have been removed.)
/// [39] element ::= EmptyElemTag | STag content ETag
@@ -846,10 +868,26 @@ pub struct ExtParsedEnt<'s> {
// TODO?: select quote version
pub struct EncodingDecl<'s>(EncName<'s>);
+impl<'s> Deref for EncodingDecl<'s> {
+ type Target = EncName<'s>;
+
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+
/// [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
#[derive(Debug)]
pub struct EncName<'s>(&'s str);
+impl<'s> Deref for EncName<'s> {
+ type Target = &'s str;
+
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+
#[derive(Debug)]
pub enum NotationDeclID<'s> {
External(ExternalID<'s>),