/** * @param string $xslFile * @param array $xsltParameters * @param Element|Tag|Field|Set $element * @param string $ns namespace * * @return \DOMDocument */ public function transform($xslFile, $xsltParameters = array(), &$element, $ns = '') { $this->load($xslFile, LIBXML_NOCDATA, $result); if (!$result) { return $element; } foreach ($xsltParameters as $name => $value) { $this->processor->setParameter($ns, $name, $value); } if ($element instanceof Set) { $processor = $this->processor; $element->each(function (Element $el) use($processor, $xslFile) { $result = $processor->transformToDoc($el); if (!$result) { $el->after($el->ownerDocument->createComment('not transformed with ' . $xslFile)); } else { $el->replace($result->documentElement, $el); } }); return $element; } $result = $this->processor->transformToDoc($element); if (!$result) { $element->after($element->ownerDocument->createComment('not transformed with ' . $xslFile)); } $element->replace($result->documentElement, $element); return $element; }
/** * @param array $body * * @return $this|Table|Document */ public function body(array $body) { foreach ($body as $rowValues) { $row = $this->body->append('tr'); foreach ($rowValues as $value) { $row->append('td')->append($value); } } return $this; }
/** * @param string|Element|Tag|Field|\DOMNode $target css selector or Element * * @return Element|Tag|Field */ public function prependTo($target) { return $target->insertBefore($target->ownerDocument->importNode($this, true), $target->firstChild); }