Skip to content

Commit

Permalink
Add reserved namespace bindings.
Browse files Browse the repository at this point in the history
This adds xml and xmlns namespace bindings. These are defined at
https://www.w3.org/TR/xml-names11/#xmlReserved.
  • Loading branch information
wt committed Aug 22, 2023
1 parent 1be35e1 commit 5d4244f
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 25 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

### New Features

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

### Bug Fixes

### Misc Changes
Expand Down
20 changes: 19 additions & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ use std::str::Utf8Error;
use std::string::FromUtf8Error;
use std::sync::Arc;

#[derive(Clone, Debug)]
pub struct ReservedNamespacePrefixError {
pub prefix: String,
}

#[derive(Clone, Debug)]
pub struct ReservedNamespaceNameError {
pub name: String,
}

/// The error type used by this crate.
#[derive(Clone, Debug)]
pub enum Error {
Expand Down Expand Up @@ -45,6 +55,8 @@ pub enum Error {
InvalidAttr(AttrError),
/// Escape error
EscapeError(EscapeError),
ReservedNamespacePrefixError(ReservedNamespacePrefixError),
ReservedNamespaceNameError(ReservedNamespaceNameError),
/// Specified namespace prefix is unknown, cannot resolve namespace for it
UnknownPrefix(Vec<u8>),
}
Expand Down Expand Up @@ -120,7 +132,13 @@ impl fmt::Display for Error {
f.write_str("Unknown namespace prefix '")?;
write_byte_string(f, prefix)?;
f.write_str("'")
}
},
Error::ReservedNamespacePrefixError(e) => write!(
f, "The namespace prefix `{}` is invalid.", e.prefix
),
Error::ReservedNamespaceNameError(e) => write!(
f, "The namespace name `{}` is invalid.", e.name
),
}
}
}
Expand Down
Loading

0 comments on commit 5d4244f

Please sign in to comment.