hml_rs/names/
tag.rs

1//a Imports
2use super::{Attributes, Name, NamespaceStack};
3use crate::MarkupResult;
4
5//a Tag
6//tp Tag
7/// A markup tag consists of a name (possibly within a namespace) and
8/// a list of attributes (which are name/value pairs)
9#[derive(Debug)]
10pub struct Tag {
11    /// Name with prefix *and URI from namespace stack*
12    ///
13    /// Note that the Name depends on the Namespace attributes within the tag
14    pub name: Name,
15
16    /// Attributes for the tag, including any local namespaces for the tag
17    pub attributes: Attributes,
18}
19
20//ip Tag
21impl Tag {
22    //fp new
23    /// Create a new [Tag] from a namespace and name strings, and an
24    /// attribute list
25    pub fn new(
26        ns_stack: &mut NamespaceStack,
27        ns: &str,
28        name: &str,
29        attributes: Attributes,
30    ) -> MarkupResult<Self> {
31        let name = Name::new(ns_stack, ns, name)?;
32        Ok(Self { name, attributes })
33    }
34}