Exemplo n.º 1
0
 /**
  * @inherit
  */
 protected function insertTemplateLogic(array $arguments, \DOMElement $node)
 {
     $template = $node->ownerDocument;
     $listName = $this->tag->getRelativePath();
     // find existing or initiate new table row template
     if ($this->isListItemTemplateExist($listName, $template) === false) {
         $rowTemplate = $template->createElementNS(Processor::XSL_NS, 'xsl:template');
         $rowTemplate->setAttribute('name', $listName);
         // find row node
         $rowNode = XMLHelper::parentUntil('w:p', $node);
         // call-template for each row
         $foreachNode = $template->createElementNS(Processor::XSL_NS, 'xsl:for-each');
         $foreachNode->setAttribute('select', '/' . Processor::VALUE_NODE . '/' . $listName . '/item');
         $callTemplateNode = $template->createElementNS(Processor::XSL_NS, 'xsl:call-template');
         $callTemplateNode->setAttribute('name', $listName);
         $foreachNode->appendChild($callTemplateNode);
         // insert call-template before moving
         $rowNode->parentNode->insertBefore($foreachNode, $rowNode);
         // move node into row template
         $rowTemplate->appendChild($rowNode);
         $template->documentElement->appendChild($rowTemplate);
     }
     // FIXME пофиксить повторное использование функции
     Processor::insertTemplateLogic($this->tag->getTextContent(), '.', $node);
 }
Exemplo n.º 2
0
 /**
  * Create DOMDocument and encode array into XML recursively
  *
  * @param array $values
  * @return \DOMDocument
  */
 private function createValuesDocument(array $values)
 {
     $document = new \DOMDocument('1.0', 'UTF-8');
     $tokensNode = $document->createElement(Processor::VALUE_NODE);
     $document->appendChild($tokensNode);
     XMLHelper::xmlEncode($values, $tokensNode, $document);
     return $document;
 }