MCPcopy Create free account
hub / github.com/daisy/MathCAT / validate_one_node

Function validate_one_node

src/xpath_functions.rs:59–66  ·  view source on GitHub ↗

make sure that there is only one node in the NodeSet Returns the node or an Error

(nodes: Nodeset<'n>, func_name: &str)

Source from the content-addressed store, hash-verified

57// make sure that there is only one node in the NodeSet
58// Returns the node or an Error
59pub fn validate_one_node<'n>(nodes: Nodeset<'n>, func_name: &str) -> Result<Node<'n>, Error> {
60 if nodes.size() == 0 {
61 return Err(Error::Other(format!("Missing argument for {}", func_name)));
62 } else if nodes.size() > 1 {
63 return Err( Error::Other(format!("{} arguments for {}; expected 1 argument", nodes.size(), func_name)) );
64 }
65 return Ok( nodes.iter().next().unwrap() );
66}
67
68// Return true if the element's name is 'name'
69fn is_tag(e: Element, name: &str) -> bool {

Callers 2

evaluateMethod · 0.85
evaluateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected