Example #1
0
 /**
  * Convert documents between two formats
  *
  * Convert documents of the given type to the requested type.
  *
  * @param ezcDocumentXmlBase $doc
  * @return ezcDocumentXmlBase
  */
 public function convert($doc)
 {
     // Create XSLT processor, if not yet initialized
     if ($this->xsltProcessor === null) {
         $stylesheet = new DOMDocument();
         $stylesheet->load($this->options->xslt);
         $this->xsltProcessor = new XSLTProcessor();
         $this->xsltProcessor->importStyleSheet($stylesheet);
     }
     // Set provided parameters.
     foreach ($this->options->parameters as $namespace => $parameters) {
         foreach ($parameters as $option => $value) {
             $this->xsltProcessor->setParameter($namespace, $option, $value);
         }
     }
     // We want to handle the occured errors ourselves.
     $oldErrorHandling = libxml_use_internal_errors(true);
     // Transform input document
     $dom = $this->xsltProcessor->transformToDoc($doc->getDomDocument());
     $errors = $this->options->failOnError ? libxml_get_errors() : null;
     libxml_clear_errors();
     libxml_use_internal_errors($oldErrorHandling);
     // If there are errors and the error handling is activated throw an
     // exception with the occured errors.
     if ($errors) {
         throw new ezcDocumentErroneousXmlException($errors);
     }
     // Reset parameters, so they are not automatically applied to the next
     // traansformation.
     foreach ($this->options->parameters as $namespace => $parameters) {
         foreach ($parameters as $option => $value) {
             $this->xsltProcessor->removeParameter($namespace, $option);
         }
     }
     // Build document from transformation and return that.
     return $this->buildDocument($dom);
 }
Example #2
0
File: odt.php Project: bmdevel/ezc
 /**
  * Construct ODT document.
  *
  * @ignore
  * @param ezcDocumentOdtOptions $options
  * @return void
  */
 public function __construct(ezcDocumentOdtOptions $options = null)
 {
     parent::__construct($options === null ? new ezcDocumentOdtOptions() : $options);
     $this->filters = array(new ezcDocumentOdtImageFilter($this->options), new ezcDocumentOdtElementFilter(), new ezcDocumentOdtStyleFilter());
 }
Example #3
0
 /**
  * Construct document xml base.
  *
  * @ignore
  * @param ezcDocumentEzXmlOptions $options
  * @return void
  */
 public function __construct(ezcDocumentEzXmlOptions $options = null)
 {
     parent::__construct($options === null ? new ezcDocumentEzXmlOptions() : $options);
 }
Example #4
0
 /**
  * Construct document xml base.
  *
  * @ignore
  * @param ezcDocumentXhtmlOptions $options
  * @return void
  */
 public function __construct(ezcDocumentXhtmlOptions $options = null)
 {
     parent::__construct($options === null ? new ezcDocumentXhtmlOptions() : $options);
     $this->filters = array(new ezcDocumentXhtmlElementFilter(), new ezcDocumentXhtmlMetadataFilter());
 }