/** * @return SiteDoc */ function getDoc() { if (!$this->siteDoc) { $this->siteDoc = XmlSiteDocBuilder::create($this->xmlDocPath)->build(); } return $this->siteDoc; }
{ if ($m) { message($m); echo PHP_EOL; } help(); exit(1); } function help() { global $argv; echo <<<EOT Usage: {$argv[0]} document.xml The HTML-rendered result is directed to stdout. EOT; } if (!isset($argv[1])) { stop(); } $docPath = realpath($argv[1]); if (!is_file($argv[1])) { stop('Incorrect path to an XML document'); } $siteDocBuilder = new XmlSiteDocBuilder($docPath); $siteDoc = $siteDocBuilder->build(); $renderer = new SiteDocContentBlockRenderer(); foreach ($siteDoc->getChapters() as $chapter) { echo $chapter->toHtml($renderer); }