xml_dom/level2/ext/
trait_impls.rs1use crate::level2::dom_impl::Implementation;
2use crate::level2::ext::decl::*;
3use crate::level2::ext::options::ProcessingOptions;
4use crate::level2::ext::traits::*;
5use crate::level2::node_impl::*;
6use crate::level2::trait_impls::create_document_with_options;
7use crate::shared::error::*;
8use tracing::warn;
9
10impl DocumentDecl for RefNode {
15 fn xml_declaration(&self) -> Option<XmlDecl> {
16 let ref_self = self.borrow();
17 if let Extension::Document {
18 i_xml_declaration, ..
19 } = &ref_self.i_extension
20 {
21 i_xml_declaration.clone()
22 } else {
23 warn!("{}", MSG_INVALID_EXTENSION);
24 None
25 }
26 }
27
28 fn set_xml_declaration(&mut self, xml_decl: XmlDecl) -> Result<()> {
29 let mut mut_self = self.borrow_mut();
30 if let Extension::Document {
31 i_xml_declaration, ..
32 } = &mut mut_self.i_extension
33 {
34 *i_xml_declaration = Some(xml_decl);
35 Ok(())
36 } else {
37 warn!("{}", MSG_INVALID_EXTENSION);
38 Err(Error::InvalidState)
39 }
40 }
41}
42
43impl DOMImplementation for Implementation {
46 fn create_document_with_options(
47 &self,
48 namespace_uri: Option<&str>,
49 qualified_name: Option<&str>,
50 doc_type: Option<Self::NodeRef>,
51 options: ProcessingOptions,
52 ) -> Result<Self::NodeRef> {
53 create_document_with_options(namespace_uri, qualified_name, doc_type, options)
54 }
55}