/** * * @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 setDocument(dom\handler $doc) { $sNamespace = $doc->getRoot()->getNamespace(); $parser = $this->getManager(self::PARSER_MANAGER); $builder = $parser->loadBuilderFromNS($sNamespace, null, null, $this->getScript(self::ARGUMENTS)); $builder->setDocument($doc); $result = $builder->getSchema(); $this->setSchema($result); }
protected function getClass(dom\handler $doc) { if (!($sResult = $doc->getRoot()->readx('@build:class', array(self::BUILD_PREFIX => self::BUILD_NS), false))) { $sResult = $this->readArgument('cache/class'); } return $sResult; }