| 1 | |||
| 2 | package DBIx::Romani::Query::XML::Where; | ||
| 3 | |||
| 4 | use DBIx::Romani::Query::XML::Util; | ||
| 5 | use DBIx::Romani::Query::XML::SQL; | ||
| 6 | use DBIx::Romani::Query::Comparison; | ||
| 7 | use DBIx::Romani::Query::Where; | ||
| 8 | use XML::DOM; | ||
| 9 | use strict; | ||
| 10 | |||
| 11 | use Data::Dumper; | ||
| 12 | |||
| 13 | sub create_where_from_node | ||
| 14 | { | ||
| 15 | my $op_node = shift; | ||
| 16 | |||
| 17 | my $name = $op_node->getLocalName(); | ||
| 18 | my $ns_uri = $op_node->getNamespaceURI(); | ||
| 19 | |||
| 20 | my $op; | ||
| 21 | |||
| 22 | # create the actual object | ||
| 23 | if ( $ns_uri eq $DBIx::Romani::Query::XML::Util::NS_QUERY_OPERATOR ) | ||
| 24 | { | ||
| 25 | if ( $name eq 'and' ) | ||
| 26 | { | ||
| 27 | $op = DBIx::Romani::Query::Where->new( $DBIx::Romani::Query::Where::AND ); | ||
| 28 | } | ||
| 29 | elsif ( $name eq 'equal' ) | ||
| 30 | { | ||
| 31 | $op = DBIx::Romani::Query::Comparison->new( $DBIx::Romani::Query::Comparison::EQUAL ); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 35 | if ( not defined $op ) | ||
| 36 | { | ||
| 37 | die "Unknown operator \"$ns_uri\" \"$name\""; | ||
| 38 | } | ||
| 39 | |||
| 40 | # go through the children | ||
| 41 | my $node = $op_node->getFirstChild(); | ||
| 42 | while ( defined $node ) | ||
| 43 | { | ||
| 44 | if ( $node->getNodeType() == XML::DOM::ELEMENT_NODE ) | ||
| 45 | { | ||
| 46 | # operators can hold other things regarded as where | ||
| 47 | $op->add( DBIx::Romani::Query::XML::SQL::create_where_from_node($node) ); | ||
| 48 | } | ||
| 49 | |||
| 50 | $node = $node->getNextSibling(); | ||
| 51 | } | ||
| 52 | |||
| 53 | return $op; | ||
| 54 | } | ||
| 55 | |||
| 56 | 1; | ||
| 57 |