pub struct QName {
pub prefix: Option<String>,
pub local: String,
pub uri: Option<String>,
}Expand description
An expanded name: an optional namespace URI plus a local part, with the prefix retained for display.
XPath compares names by namespace URI and local part only; the prefix is carried so that error messages and generated locations can show the name the way the document author wrote it.
§Examples
use schematron::xml::QName;
let a = QName::new(Some("inv"), "total", Some("http://example.com/i"));
let b = QName::new(Some("x"), "total", Some("http://example.com/i"));
// Different prefixes, same expanded name.
assert!(a.matches(&b));
assert_eq!(a.display_name(), "inv:total");Fields§
§prefix: Option<String>The prefix as written in the document, if any.
local: StringThe local part.
uri: Option<String>The namespace URI the prefix resolved to, if any.
Implementations§
Source§impl QName
impl QName
Sourcepub fn new(
prefix: Option<impl Into<String>>,
local: impl Into<String>,
uri: Option<impl Into<String>>,
) -> Self
pub fn new( prefix: Option<impl Into<String>>, local: impl Into<String>, uri: Option<impl Into<String>>, ) -> Self
Builds a qualified name.
Sourcepub fn matches(&self, other: &QName) -> bool
pub fn matches(&self, other: &QName) -> bool
Compares expanded names: namespace URI and local part, ignoring prefix.
Sourcepub fn matches_parts(&self, uri: Option<&str>, local: &str) -> bool
pub fn matches_parts(&self, uri: Option<&str>, local: &str) -> bool
Compares against an expanded name given as its parts.
Sourcepub fn display_name(&self) -> String
pub fn display_name(&self) -> String
The name as written, prefix:local or local.
This is what the XPath name() function returns.
Trait Implementations§
impl Eq for QName
impl StructuralPartialEq for QName
Auto Trait Implementations§
impl Freeze for QName
impl RefUnwindSafe for QName
impl Send for QName
impl Sync for QName
impl Unpin for QName
impl UnsafeUnpin for QName
impl UnwindSafe for QName
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more