use crate::document::XmlDocument;
use crate::error::Result;
use crate::node::{XmlNode, XmlRoNode};
use crate::xpath::{self, XmlContext, XmlSafeContext};
pub fn evaluate<T: AsRef<str>>(
document: &XmlDocument,
xpath_expr: T,
) -> Result<xpath::XPathResult> {
xpath::evaluate(document, xpath_expr.as_ref())
}
pub fn create_context(document: &XmlDocument) -> Result<XmlContext> {
xpath::create_context(document)
}
pub fn create_safe_context(document: &XmlDocument) -> Result<XmlSafeContext> {
xpath::create_safe_context(document)
}
pub fn find_nodes_by_xpath(
ctx: &XmlContext,
xpath_expr: &str,
node: &XmlNode,
) -> Result<Vec<XmlNode>> {
xpath::find_nodes_by_xpath(ctx, xpath_expr, node)
}
pub fn find_readonly_nodes_by_xpath(
ctx: &XmlContext,
xpath_expr: &str,
node: &XmlRoNode,
) -> Result<Vec<XmlRoNode>> {
xpath::find_readonly_nodes_by_xpath(ctx, xpath_expr, node)
}
pub fn find_safe_readonly_nodes_by_xpath(
ctx: &XmlSafeContext,
xpath_expr: &str,
node: &XmlRoNode,
) -> Result<Vec<XmlRoNode>> {
xpath::find_safe_readonly_nodes_by_xpath(ctx, xpath_expr, node)
}
pub fn find_readonly_nodes_in_elements(
ctx: &XmlContext,
node: &XmlRoNode,
elements_to_match: &[&str],
) -> Result<Vec<XmlRoNode>> {
xpath::find_readonly_nodes_in_elements(ctx, node, elements_to_match)
}
pub fn collect_text_values(xpath_value: &xpath::XPathResult) -> Vec<String> {
xpath::collect_text_values(xpath_value)
}
pub fn collect_text_value(xpath_value: &xpath::XPathResult) -> String {
xpath::collect_text_value(xpath_value)
}
pub fn get_root_node(document: &XmlDocument) -> Result<XmlNode> {
document.get_root_element()
}
pub fn get_root_readonly_node(document: &XmlDocument) -> Result<XmlRoNode> {
document.get_root_element_ro()
}
pub fn get_node_tag(node: &XmlNode) -> String {
node.qname()
}
pub fn get_readonly_node_tag(node: &XmlRoNode) -> String {
node.qname()
}
pub fn get_node_prefix(node: &XmlNode) -> String {
node.get_prefix().unwrap_or_default()
}
pub fn get_readonly_node_prefix(node: &XmlRoNode) -> String {
node.get_prefix().unwrap_or_default()
}
pub fn node_to_xml_string(document: &XmlDocument, node: &mut XmlNode) -> Result<String> {
crate::serialize::node_to_xml_string(document, node)
}
pub fn readonly_node_to_xml_string(document: &XmlDocument, node: &XmlRoNode) -> Result<String> {
crate::serialize::readonly_node_to_xml_string(document, node)
}