private function ensureVisitorSetup() { if (!$this->visitor) { $navigator = new Navigator(); $this->visitor = new CandidateTermVisitor(); $this->ensureDocumentLoaded(); $navigator->walk($this->document, $this->visitor); } }
public static function findConceptsByXPath(databox $databox, $expression) { $document = self::thesaurusFromDatabox($databox); $xpath = new DOMXPath($document); $nodes = $xpath->query($expression); $concepts = []; foreach ($nodes as $node) { $path_segments = []; $me_and_parents = [$node]; foreach (self::getElementAncestors($node) as $me_and_parents[]) { } foreach ($me_and_parents as $node) { if (Navigator::isConcept($node)) { $path_segments[] = self::conceptPathSegment($node); } else { // Silently skips invalid targeted nodes break; } } // Concept paths are have databox identifier at root level $concepts[] = new Concept(sprintf('/%d/%s', $databox->get_sbas_id(), implode('/', array_reverse($path_segments)))); } return $concepts; }