pub struct Name { /* private fields */ }
Expand description
Corresponds to attributes localName
, namespaceURI
, and prefix
on the DOM Node
interface.
Specification
localName
of type DOMString
, readonly, introduced in DOM Level 2
Returns the local part of the qualified name of this node. For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.
namespaceURI
of type DOMString
, readonly, introduced in DOM Level 2
The namespace URI of this node, or null if it is unspecified. This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time. For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.
Note: Per the Namespaces in XML Specification an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.
prefix
of type DOMString
, introduced in DOM Level 2
The namespace prefix of this node, or null if it is unspecified. Note that setting this attribute, when permitted, changes the nodeName attribute, which holds the qualified name, as well as the tagName and name attributes of the Element and Attr interfaces, when applicable. Note also that changing the prefix of an attribute that is known to have a default value, does not make a new attribute with the default value and the original prefix appear, since the namespaceURI and localName do not change. For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.
Exceptions on setting
INVALID_CHARACTER_ERR
: Raised if the specified prefix contains an illegal character.NO_MODIFICATION_ALLOWED_ERR
: Raised if this node is readonly.NAMESPACE_ERR
: Raised if the specified prefix is malformed, if the namespaceURI of this node is null, if the specified prefix is “xml” and the namespaceURI of this node is different from “http://www.w3.org/XML/1998/namespace”, if this node is an attribute and the specified prefix is “xmlns” and the namespaceURI of this node is different from “http://www.w3.org/2000/xmlns/”, or if this node is an attribute and the qualifiedName of this node is “xmlns”.
Implementations
sourceimpl Name
impl Name
sourcepub fn new_ns(namespace_uri: &str, qualified_name: &str) -> Result<Self>
pub fn new_ns(namespace_uri: &str, qualified_name: &str) -> Result<Self>
Construct a new Name
from the specified namespace URI and qualified name.
Note, errors include a malformed URI, or malformed prefix or local name.
sourcepub fn for_comment() -> Self
pub fn for_comment() -> Self
Return the reserved name for Comment
nodes
sourcepub fn for_document() -> Self
pub fn for_document() -> Self
Return the reserved name for Document
nodes
sourcepub fn for_document_fragment() -> Self
pub fn for_document_fragment() -> Self
Return the reserved name for Document
nodes
sourcepub fn for_public_id() -> Self
pub fn for_public_id() -> Self
Return the reserved name for DocumentType
public_id
attribute
sourcepub fn for_system_id() -> Self
pub fn for_system_id() -> Self
Return the reserved name for DocumentType
system_id
attribute
sourcepub fn is_namespace_attribute(&self) -> bool
pub fn is_namespace_attribute(&self) -> bool
Does this appear to be an xmlns
attribute.
sourcepub fn for_namespace(prefix: Option<&str>) -> Self
pub fn for_namespace(prefix: Option<&str>) -> Self
Construct a name for an xmlns
attribute.
sourcepub fn is_id_attribute(&self, lax: bool) -> bool
pub fn is_id_attribute(&self, lax: bool) -> bool
Does this appear to be an id
attribute.
sourcepub fn for_xml_id() -> Self
pub fn for_xml_id() -> Self
Construct a name for an xml:id
attribute.
///
sourcepub fn namespace_uri(&self) -> &Option<String>
pub fn namespace_uri(&self) -> &Option<String>
Return this name’s namespace URI.
sourcepub fn local_name(&self) -> &String
pub fn local_name(&self) -> &String
Return this name’s local name.
Trait Implementations
impl Eq for Name
impl StructuralEq for Name
impl StructuralPartialEq for Name
Auto Trait Implementations
impl RefUnwindSafe for Name
impl Send for Name
impl Sync for Name
impl Unpin for Name
impl UnwindSafe for Name
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more