pub struct BufferDocumentBuilder<'a> { /* private fields */ }Expand description
Builds a BufferDocument incrementally via a push API.
Implementations§
Source§impl<'a> BufferDocumentBuilder<'a>
impl<'a> BufferDocumentBuilder<'a>
Sourcepub fn new(
arena: &'a Bump,
names: &'a NameTable,
schema_set: Option<&'a SchemaSet>,
options: BufferDocumentOptions,
) -> Result<Self, BufferDocumentError>
pub fn new( arena: &'a Bump, names: &'a NameTable, schema_set: Option<&'a SchemaSet>, options: BufferDocumentOptions, ) -> Result<Self, BufferDocumentError>
Creates a new builder.
If schema_set is Some, uses its name_table; otherwise uses names.
Sourcepub fn start_element(
&mut self,
local_name: &str,
ns_uri: &str,
prefix: &str,
ns_declarations: &[(&str, &str)],
) -> Result<u32, BufferDocumentError>
pub fn start_element( &mut self, local_name: &str, ns_uri: &str, prefix: &str, ns_declarations: &[(&str, &str)], ) -> Result<u32, BufferDocumentError>
Opens an element node.
ns_declarations is a list of (prefix, namespace_uri) pairs for xmlns
declarations on this element.
Sourcepub fn attribute(
&mut self,
local_name: &str,
ns_uri: &str,
prefix: &str,
value: &str,
) -> Result<u32, BufferDocumentError>
pub fn attribute( &mut self, local_name: &str, ns_uri: &str, prefix: &str, value: &str, ) -> Result<u32, BufferDocumentError>
Adds an attribute to the current element (two-node pair).
Sourcepub fn end_of_attributes(&mut self)
pub fn end_of_attributes(&mut self)
Marks the end of attributes; subsequent content nodes are children.
Sourcepub fn text(&mut self, value: &str)
pub fn text(&mut self, value: &str)
Accumulates text content; coalesced on the next structural event.
Sourcepub fn processing_instruction(
&mut self,
target: &str,
data: &str,
) -> Result<(), BufferDocumentError>
pub fn processing_instruction( &mut self, target: &str, data: &str, ) -> Result<(), BufferDocumentError>
Adds a processing instruction (two-node pair: PI + ChildValue).
Sourcepub fn end_element(&mut self) -> Result<(), BufferDocumentError>
pub fn end_element(&mut self) -> Result<(), BufferDocumentError>
Closes the current element.
Sourcepub fn finalize(self) -> Result<BufferDocument<'a>, BufferDocumentError>
pub fn finalize(self) -> Result<BufferDocument<'a>, BufferDocumentError>
Finalizes the document, appending the Nul sentinel.
Sourcepub fn set_node_binding(
&mut self,
node_ref: u32,
binding: NodeSchemaBinding,
) -> Result<bool, BufferDocumentError>
pub fn set_node_binding( &mut self, node_ref: u32, binding: NodeSchemaBinding, ) -> Result<bool, BufferDocumentError>
Sets the schema binding on a node, returning true if the type is complex.
Returns BufferDocumentError::Overflow if the binding table is full.
Sourcepub fn register_xml_id(
&mut self,
id: &str,
elem_ref: u32,
) -> Result<(), BufferDocumentError>
pub fn register_xml_id( &mut self, id: &str, elem_ref: u32, ) -> Result<(), BufferDocumentError>
Registers an xml:id value for the given element.
Returns BufferDocumentError::DuplicateId if the id has already
been registered. This is a no-op in Fragment mode.
Sourcepub fn track_source_locations(&self) -> bool
pub fn track_source_locations(&self) -> bool
Returns true when source location tracking is enabled.
Sourcepub fn set_source_span(&mut self, node_ref: u32, span: SourceSpan)
pub fn set_source_span(&mut self, node_ref: u32, span: SourceSpan)
Records a completed source span for a node.
Sourcepub fn build<R: BufRead>(
self,
reader: R,
) -> Result<BufferDocument<'a>, BufferDocumentError>
pub fn build<R: BufRead>( self, reader: R, ) -> Result<BufferDocument<'a>, BufferDocumentError>
Builds the document from a quick-xml event stream.