Romani/Query/XML/Function.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 59 CC 6 SCAR 30.2
CC
6
Cov
0%
create_function_from_node
42.0
BEGIN
2.0
BEGIN
2.0
CRAP 20.5
1  
2 package DBIx::Romani::Query::XML::Function;
3  
4 use DBIx::Romani::Query::XML::Util;
5 use DBIx::Romani::Query::XML::TTT;
6 use DBIx::Romani::Query::XML::SQL;
7 use DBIx::Romani::Query::Function::Count;
8 use XML::DOM;
9 use strict;
10  
11 use Data::Dumper;
12  
13 sub create_function_from_node
14 {
15 my $func_node = shift;
16  
17 my $name = $func_node->getLocalName();
18 my $ns_uri = $func_node->getNamespaceURI();
19  
20 my $func;
21  
22 if ( $ns_uri eq $DBIx::Romani::Query::XML::Util::NS_QUERY_FUNCTION )
23 {
24 if ( $name eq 'count' )
25 {
26 $func = DBIx::Romani::Query::Function::Count->new();
27 $func->set_distinct( DBIx::Romani::Query::XML::Util::get_boolean( $func_node, 'distinct', 0 ) );
28 }
29 }
30  
31 if ( not defined $func )
32 {
33 die "Unknown function tag \"$ns_uri\" \"$name\"";
34 }
35  
36 # add the children to the function
37 my $node = $func_node->getFirstChild();
38 while ( defined $node )
39 {
40 if ( $node->getNodeType() == XML::DOM::ELEMENT_NODE )
41 {
42 my $value = DBIx::Romani::Query::XML::SQL::create_value_from_node( $node );
43 if ( not defined $value )
44 {
45 die "Function \"$name\" contains invalid value";
46 }
47  
48 $func->add( $value );
49 }
50  
51 $node = $node->getNextSibling();
52 }
53  
54 return $func;
55 }
56  
57 1;
58