use quick_xml::events::{BytesRef, BytesText};
use crate::datasets::sec::error::{Result, SecError};
fn append_unescaped_text(target: &mut String, text: &BytesText<'_>, context: &str) -> Result<()> {
let decoded = text
.decode()
.map_err(|error| SecError::Decode(format!("{context}: {error}")))?;
let unescaped = quick_xml::escape::unescape(&decoded)
.map_err(|error| SecError::Decode(format!("{context}: {error}")))?;
target.push_str(&unescaped);
Ok(())
}
fn append_xml_reference(
target: &mut String,
reference: &BytesRef<'_>,
context: &str,
) -> Result<()> {
if let Some(character) = reference
.resolve_char_ref()
.map_err(|error| SecError::Decode(format!("{context}: {error}")))?
{
target.push(character);
return Ok(());
}
let name = reference
.decode()
.map_err(|error| SecError::Decode(format!("{context}: {error}")))?;
let value = quick_xml::escape::resolve_predefined_entity(&name)
.ok_or_else(|| SecError::Decode(format!("{context}: unrecognized entity `{name}`")))?;
target.push_str(value);
Ok(())
}
pub mod earnings_release;
pub mod eightk;
pub mod exhibit21;
pub mod f13f;
pub mod form144;
pub mod form4;
pub mod formd;
pub mod html_text;
pub mod offering;
pub mod officer_change;
pub mod ownership_table;
pub mod proxy_governance;
pub mod related_party;
pub mod sc13d;
pub mod submissions;
pub mod summary_compensation;
pub mod xbrl_facts;