Skip to content

Commit b03ef36

Browse files
committed
Add reserved namespace bindings.
This adds xml and xmlns namespace bindings. These are defined at https://www.w3.org/TR/xml-names11/#xmlReserved.
1 parent 1be35e1 commit b03ef36

File tree

4 files changed

+208
-25
lines changed

4 files changed

+208
-25
lines changed

Changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212

1313
### New Features
1414

15+
- [#541]: Deserialize specially named `$text` enum variant in [externally tagged]
16+
enums from textual content
17+
- [#545]: Resolve well-known namespaces (xml and xmlns) to their approrpriate URIs.
18+
Also, enforce namespace constraints related to these well-known namespaces.
19+
1520
### Bug Fixes
1621

1722
### Misc Changes

src/errors.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ use std::str::Utf8Error;
99
use std::string::FromUtf8Error;
1010
use std::sync::Arc;
1111

12+
#[derive(Clone, Debug)]
13+
pub struct ReservedNamespacePrefixError {
14+
pub prefix: String,
15+
}
16+
17+
#[derive(Clone, Debug)]
18+
pub struct ReservedNamespaceNameError {
19+
pub name: String,
20+
}
21+
1222
/// The error type used by this crate.
1323
#[derive(Clone, Debug)]
1424
pub enum Error {
@@ -45,6 +55,10 @@ pub enum Error {
4555
InvalidAttr(AttrError),
4656
/// Escape error
4757
EscapeError(EscapeError),
58+
/// Error for when a reserved namespace is explicity set incorrectly
59+
ReservedNamespacePrefixError(ReservedNamespacePrefixError),
60+
/// Error for when a reserved namespace name is used incorrectly
61+
ReservedNamespaceNameError(ReservedNamespaceNameError),
4862
/// Specified namespace prefix is unknown, cannot resolve namespace for it
4963
UnknownPrefix(Vec<u8>),
5064
}
@@ -120,7 +134,13 @@ impl fmt::Display for Error {
120134
f.write_str("Unknown namespace prefix '")?;
121135
write_byte_string(f, prefix)?;
122136
f.write_str("'")
123-
}
137+
},
138+
Error::ReservedNamespacePrefixError(e) => write!(
139+
f, "The namespace prefix `{}` is invalid.", e.prefix
140+
),
141+
Error::ReservedNamespaceNameError(e) => write!(
142+
f, "The namespace name `{}` is invalid.", e.name
143+
),
124144
}
125145
}
126146
}

0 commit comments

Comments
 (0)