/** * * @param \sylma\dom\handler $doc * @param type $bXML * @return \sylma\dom\handler */ public function parseDocument(dom\handler $doc, $bXML = true) { // WARNING, XML_Document typed can cause crashes $mResult = null; $dom = $this->getControler(); if ($doc->isEmpty()) { $doc->throwException('Cannot parse empty document'); } if ($this->isEmpty()) { $this->throwException(t('Cannot parse empty template')); } $this->includeExternals(); libxml_use_internal_errors(true); $this->getProcessor()->importStylesheet($this->getDocument()); $this->retrieveErrors(); libxml_clear_errors(); if ($bXML) { $doc->getRoot(); $mResult = $this->getProcessor()->transformToDoc($doc->getDocument()); if ($mResult && $mResult->documentElement) { $mResult = $dom->create('handler', array($mResult)); } else { $this->throwException('No result on parsing'); } } else { $mResult = $this->getProcessor()->transformToXML($doc->getDocument()); } $this->retrieveErrors(); libxml_clear_errors(); libxml_use_internal_errors(false); $dom->addStat('parse', array($this, $doc)); return $mResult; }
public function clean(dom\handler $doc) { $sResult = ''; if (!$doc->isEmpty()) { $sResult = $this->cleanValid($doc); } return $sResult; }