/**
  * SyndicatedPostXPathQuery::match
  *
  * @param string $path
  * @return array
  */
 public function match($r = array())
 {
     $path = $this->parsedPath;
     $r = wp_parse_args($r, array("type" => SIMPLEPIE_TYPE_ATOM_10, "xmlns" => array(), "map" => array(), "context" => array(), "parent" => array(), "format" => "string"));
     $this->feed_type = $r['type'];
     $this->xmlns = $r['xmlns'];
     // Start out with a get_item_tags query.
     $node = '';
     while (strlen($node) == 0 and !is_null($node)) {
         $node = array_shift($path);
     }
     if (is_string($node) and isset($r['map'][$node])) {
         $data = $r['map'][$node];
         $node = array_shift($path);
     } else {
         $data = $r['map']['/'];
     }
     $matches = $data;
     while (!is_null($node)) {
         if (is_object($node) or strlen($node) > 0) {
             list($axis, $element) = $this->xpath_name_and_axis($node);
             if ('self' == $axis) {
                 if (is_object($element) and property_exists($element, 'verb')) {
                     $subq = new self(array("path" => $element->query));
                     $result = $subq->match(array("type" => $r['type'], "xmlns" => $r['xmlns'], "map" => array("/" => $matches), "context" => $matches, "parent" => $r['parent'], "format" => "object"));
                     // when format = 'object' we should get back
                     // a sparse array of arrays, with indices = indices
                     // from the input array, each element = an array of
                     // one or more matching elements
                     if ($element->verb = 'has' and is_array($result)) {
                         $results = array();
                         foreach (array_keys($result) as $a) {
                             $results[$a] = $matches[$a];
                         }
                         $matches = $results;
                         $data = $matches;
                     }
                 } elseif (is_numeric($node)) {
                     // according to W3C, sequence starts at position 1, not 0
                     // so subtract 1 to line up with PHP array starting at 0
                     $idx = intval($element) - 1;
                     if (isset($matches[$idx])) {
                         $data = array($idx => $matches[$idx]);
                     } else {
                         $data = array();
                     }
                     $matches = array($idx => $data);
                 }
             } else {
                 $matches = array();
                 foreach ($data as $idx => $datum) {
                     if (!is_string($datum) and isset($datum[$axis])) {
                         foreach ($datum[$axis] as $ns => $elements) {
                             if (isset($elements[$element])) {
                                 // Potential match.
                                 // Check namespace.
                                 if (is_string($elements[$element])) {
                                     // Attribute
                                     $addenda = array($elements[$element]);
                                     $contexts = array($datum);
                                     // Element
                                 } else {
                                     $addenda = $elements[$element];
                                     $contexts = $elements[$element];
                                 }
                                 foreach ($addenda as $index => $addendum) {
                                     $context = $contexts[$index];
                                     $namespaces = $this->xpath_possible_namespaces($node, $context);
                                     if (in_array($ns, $namespaces)) {
                                         $matches[] = $addendum;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $data = $matches;
             }
         }
         $node = array_shift($path);
     }
     $matches = array();
     foreach ($data as $idx => $datum) {
         if ($r['format'] == 'string') {
             if (is_string($datum)) {
                 $matches[] = $datum;
             } elseif (isset($datum['data'])) {
                 $matches[] = $datum['data'];
             }
         } else {
             $matches[$idx] = $datum;
         }
     }
     return $matches;
 }