oxml_drawing/
namespace.rs1use oxml_core::OxmlError;
2use quick_xml::XmlVersion;
3use quick_xml::events::BytesStart;
4
5pub const A_NS: &str = "http://schemas.openxmlformats.org/drawingml/2006/main";
6pub const A_PREFIX: &str = "a";
7pub const PIC_NS: &str = "http://schemas.openxmlformats.org/drawingml/2006/picture";
8pub const PIC_PREFIX: &str = "pic";
9
10pub(crate) fn reject_conflicting_a_prefix(element: &BytesStart<'_>) -> Result<(), OxmlError> {
15 for attribute in element.attributes() {
16 let attribute = attribute.map_err(OxmlError::from)?;
17 if attribute.key.as_ref() == b"xmlns:a" {
18 let value = attribute
19 .decoded_and_normalized_value(XmlVersion::Implicit1_0, element.decoder())
20 .map_err(OxmlError::from)?;
21 if value != A_NS {
22 return Err(OxmlError::InvalidValue(
23 "xmlns:a conflicts with the fixed DrawingML writer namespace".to_owned(),
24 ));
25 }
26 }
27 }
28 Ok(())
29}