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 18, 2023
1 parent 1be35e1 commit 5f170cd
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 25 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

### New Features

- [#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 5f170cd

Please sign in to comment.