use crate::level2::dom_impl::Implementation;
use crate::level2::ext::traits::DOMImplementation;
use crate::level2::node_impl::{NodeImpl, RefNode};
use crate::shared::error::Result;
use crate::shared::name::Name;
use std::str::FromStr;
const THIS_IMPLEMENTATION: &'static dyn DOMImplementation<NodeRef = RefNode> = &Implementation {};
pub fn get_implementation_ext() -> &'static dyn DOMImplementation<NodeRef = RefNode> {
THIS_IMPLEMENTATION as &'static dyn DOMImplementation<NodeRef = RefNode>
}
pub fn create_notation(
owner_document: RefNode,
notation_name: &str,
public_id: Option<&str>,
system_id: Option<&str>,
) -> Result<RefNode> {
let name = Name::from_str(notation_name)?;
let node_impl =
NodeImpl::new_notation(Some(owner_document.downgrade()), name, public_id, system_id);
Ok(RefNode::new(node_impl))
}
pub fn create_entity(
owner_document: RefNode,
notation_name: &str,
public_id: Option<&str>,
system_id: Option<&str>,
) -> Result<RefNode> {
let name = Name::from_str(notation_name)?;
let node_impl =
NodeImpl::new_entity(Some(owner_document.downgrade()), name, public_id, system_id);
Ok(RefNode::new(node_impl))
}
pub fn create_internal_entity(
owner_document: RefNode,
notation_name: &str,
value: &str,
) -> Result<RefNode> {
let name = Name::from_str(notation_name)?;
let node_impl = NodeImpl::new_internal_entity(Some(owner_document.downgrade()), name, value);
Ok(RefNode::new(node_impl))
}