XmlFragment

Struct XmlFragment 

Source
pub struct XmlFragment {
    pub raw_content: String,
    pub element_name: String,
    pub namespace_uri: Option<String>,
    pub namespace_prefix: Option<String>,
    pub namespace_declarations: IndexMap<String, String>,
    pub attributes: IndexMap<String, String>,
    pub children: Vec<XmlFragment>,
    pub text_content: Option<String>,
    pub processing_instructions: Vec<ProcessingInstruction>,
    pub comments: Vec<Comment>,
    pub position_hint: Option<usize>,
    pub preserve_formatting: bool,
}
Expand description

Comprehensive XML fragment preservation for round-trip fidelity

Fields§

§raw_content: String

The raw XML content as a string

§element_name: String

Element name (local name without namespace prefix)

§namespace_uri: Option<String>

Namespace URI for this element

§namespace_prefix: Option<String>

Namespace prefix used in the original XML

§namespace_declarations: IndexMap<String, String>

All namespace declarations on this element

§attributes: IndexMap<String, String>

All attributes on this element (including namespaced ones)

§children: Vec<XmlFragment>

Child XML fragments (for nested unknown elements)

§text_content: Option<String>

Text content (if this element contains only text)

§processing_instructions: Vec<ProcessingInstruction>

Processing instructions within this fragment

§comments: Vec<Comment>

Comments within this fragment

§position_hint: Option<usize>

Position hint for canonical ordering

§preserve_formatting: bool

Whether this fragment should be preserved as-is (no canonicalization)

Implementations§

Source§

impl XmlFragment

Source

pub fn new(element_name: String, raw_content: String) -> Self

Create a new XML fragment

Source

pub fn with_namespace( element_name: String, namespace_uri: Option<String>, namespace_prefix: Option<String>, raw_content: String, ) -> Self

Create a fragment with namespace information

Source

pub fn qualified_name(&self) -> String

Get the qualified name for this element

Source

pub fn is_from_namespace(&self, namespace_uri: &str) -> bool

Check if this fragment is from a specific namespace

Source

pub fn add_child(&mut self, child: XmlFragment)

Add a child fragment

Source

pub fn add_attribute(&mut self, name: String, value: String)

Add an attribute

Source

pub fn add_namespace_declaration(&mut self, prefix: String, uri: String)

Add a namespace declaration

Source

pub fn set_position_hint(&mut self, position: usize)

Set position hint for canonical ordering

Source

pub fn preserve_formatting(&mut self)

Mark this fragment to preserve original formatting

Source

pub fn to_canonical_xml(&self, indent_level: usize) -> String

Get the canonical XML representation with proper formatting

Trait Implementations§

Source§

impl Clone for XmlFragment

Source§

fn clone(&self) -> XmlFragment

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for XmlFragment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for XmlFragment

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for XmlFragment

Source§

fn eq(&self, other: &XmlFragment) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for XmlFragment

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for XmlFragment

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,