/** * Parse the table of contents file and populate nav data */ public function parse() { $this->navData = array(); $doc = new ChaucerDomDocument(); $doc->loadHTMLFile($this->path); $xpath = new DOMXpath($doc); $xpath->registerNamespace('epub', 'http://www.idpf.org/2007/ops'); $parentElements = $xpath->query("//nav"); if (!is_null($parentElements)) { foreach ($parentElements as $parentNode) { if ($parentNode->getAttribute('epub:type') == 'toc') { $this->navData = $this->parseTocNode($parentNode, $xpath, 0, 0); } } } }
/** * Return transformed content. * * @return string */ public function getContent() { if ($this->pxeDoc) { // Turning on output formatting is suitable for debugging purposes only // $this->pxeDoc->formatOutput = true; // // Production usage requires this to be off, // so that <span>abc</span><span>def</span> doesn't come out with a space like "abc def" $this->pxeDoc->formatOutput = false; if ($this->isDocument) { return $this->pxeDoc->saveXML(); } else { return $this->pxeDoc->saveXML($this->currentElement); } } else { return ''; } }
/** * read the story that contains the information about hidden content * @param string $backingStoryId * @return boolean */ private function readXmlContentStory($backingStoryId) { $xmlContentStory = $this->tempDir . '/Stories/Story_' . $backingStoryId . '.xml'; if (!file_exists($xmlContentStory)) { $this->idmlAssembler->getProgressUpdater()->setWarning($xmlContentStory . " does not exist."); return false; } // create ChaucerDOMDocument and DOMXPath objects $doc = new ChaucerDomDocument(); $b = $doc->load($xmlContentStory); if ($b === false) { return false; } $xpath = new DOMXPath($doc); $hiddentags = $xpath->query("//XMLElement[@MarkupTag='XMLTag/ChaucerHidden']"); for ($i = 0; $i < $hiddentags->length; $i++) { $tag = $hiddentags->item($i); $this->iterativelyGetHiddenIds($tag, $this->chaucerHidden); } return true; }