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
impl XmlFragment
Sourcepub fn with_namespace(
element_name: String,
namespace_uri: Option<String>,
namespace_prefix: Option<String>,
raw_content: String,
) -> Self
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
Sourcepub fn qualified_name(&self) -> String
pub fn qualified_name(&self) -> String
Get the qualified name for this element
Sourcepub fn is_from_namespace(&self, namespace_uri: &str) -> bool
pub fn is_from_namespace(&self, namespace_uri: &str) -> bool
Check if this fragment is from a specific namespace
Sourcepub fn add_child(&mut self, child: XmlFragment)
pub fn add_child(&mut self, child: XmlFragment)
Add a child fragment
Sourcepub fn add_attribute(&mut self, name: String, value: String)
pub fn add_attribute(&mut self, name: String, value: String)
Add an attribute
Sourcepub fn add_namespace_declaration(&mut self, prefix: String, uri: String)
pub fn add_namespace_declaration(&mut self, prefix: String, uri: String)
Add a namespace declaration
Sourcepub fn set_position_hint(&mut self, position: usize)
pub fn set_position_hint(&mut self, position: usize)
Set position hint for canonical ordering
Sourcepub fn preserve_formatting(&mut self)
pub fn preserve_formatting(&mut self)
Mark this fragment to preserve original formatting
Sourcepub fn to_canonical_xml(&self, indent_level: usize) -> String
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
impl Clone for XmlFragment
Source§fn clone(&self) -> XmlFragment
fn clone(&self) -> XmlFragment
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more