/**
  * Initializes the XPathFlattenRecord from the given parameter array.
  * @param $spec associative array of options. See class-level documentation for details.
  */
 function __construct($spec)
 {
     FlattenRecord::__construct($spec);
 }
 public function extractRecord($data)
 {
     if ($this->transformer) {
         $rec = $this->transformer->extractRecord($data);
     } else {
         $rec = FlattenRecord::naiveResolvePath($data, $this->dataPath);
     }
     return $rec;
 }
 public static function naiveResolvePath($data, $path, $split = true)
 {
     if (is_object($data)) {
         if ($dom instanceof DOMNode) {
             throw new MWException("naiveResolvePath does not like DOMNode objects");
         }
         $data = wfObjectToArray($data);
     }
     if (!is_array($data) || $path === '.') {
         return $data;
     }
     if ($split && is_string($path)) {
         $path = DataTransclusionSource::splitList($path, '/');
     }
     if (is_string($path) || is_int($path)) {
         return @$data[$path];
     }
     if (!$path) {
         return $data;
     }
     $p = array_shift($path);
     if (is_string($p) && preg_match('/^(@)?(\\d+)$/', $p, $m)) {
         //numberic index
         $i = (int) $m[2];
         if ($m[1]) {
             //meta-index
             $k = array_keys($data);
             $p = $k[$i];
         }
     }
     if (!isset($data[$p])) {
         return false;
     }
     $next = $data[$p];
     if ($next && $path) {
         return FlattenRecord::naiveResolvePath($next, $path);
     } else {
         return $next;
     }
     //TODO: named components. separator??
 }
 /**
  * Resolvs the given path on the $data structure. Delegates to FlattenRecord::naiveResolvePath(),
  * but may be overridden to change that.
  */
 public function resolvePath($data, $path, $split = true)
 {
     return FlattenRecord::naiveResolvePath($data, $path, $split);
 }