Skip to content

Commit b2f1be3

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 b2f1be3

File tree

6 files changed

+211
-27
lines changed

6 files changed

+211
-27
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v3
17-
- uses: dtolnay/rust-toolchain@1.52.0
17+
- uses: dtolnay/rust-toolchain@1.53.0
1818
- run: cargo check
1919

2020
minimal-versions:

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repository = "https://github.com/tafia/quick-xml"
1010
keywords = ["xml", "serde", "parser", "writer", "html"]
1111
categories = ["asynchronous", "encoding", "parsing", "parser-implementations"]
1212
license = "MIT"
13-
rust-version = "1.52"
13+
rust-version = "1.53"
1414
include = ["src/*", "LICENSE-MIT.md", "README.md"]
1515

1616
[dependencies]

Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@
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
1823

24+
- [#541]: Updated MSRV to 1.53 due to https://doc.rust-lang.org/edition-guide/rust-2021/IntoIterator-for-arrays.html
1925

2026
## 0.30.0 -- 2023-07-23
2127

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)