示例#1
0
 /**
  * @param \DOMDocumentFragment $fragment
  * @return \BaseXMS\UiComponent\UiComponent
  */
 public function fillFragment(\DOMDocumentFragment $fragment)
 {
     $result = $this->getRenderResult();
     if ($result instanceof RenderResult) {
         $fragment->appendXML($this->getRenderResult()->getOutput());
     } else {
         $this->getUiComposer()->getServiceLocator()->get('log')->warn('Could not get a RenderResult: ' . get_class($this));
     }
     return $this;
 }
示例#2
0
 /**
  * @param \DOMDocumentFragment $target
  * @param \DOMNode $node
  */
 private static function add($target, $node)
 {
     if ($node instanceof \DOMDocument) {
         if ($node->documentElement instanceof \DOMElement) {
             $target->appendChild($target->ownerDocument->importNode($node->documentElement, TRUE));
         }
     } elseif ($node->ownerDocument !== $target->ownerDocument) {
         $target->appendChild($target->ownerDocument->importNode($node, TRUE));
     } else {
         $target->appendChild($node->cloneNode(TRUE));
     }
 }
 /**
  * Wrapper to standard method with exception support
  *
  * @param string $str Data string to parse and append
  *
  * @return boolean true on success
  */
 public function appendXML($str)
 {
     if (!parent::appendXML($str)) {
         throw new fDOMException('Appending xml string failed', fDOMException::ParseError);
     }
     return true;
 }
<?php

$fragment = new DOMDocumentFragment();
$fragment->__construct();
var_dump($fragment);
<?php

$fragment = new DOMDocumentFragment();
$fragment->appendXML('<bait>crankbait</bait>');
$document->appendChild($fragment);
示例#6
0
 /**
  * Append an xml to the fragment, it can use namespace prefixes defined on the fragment object.
  *
  * @param string $data
  * @param null|array|\Traversable|\DOMElement $namespaces
  * @return bool
  */
 public function appendXml($data, $namespaces = NULL)
 {
     $namespaces = $this->namespaces($namespaces);
     if (empty($namespaces)) {
         return parent::appendXml($data);
     } else {
         $fragment = '<fragment';
         foreach ($namespaces as $key => $xmlns) {
             $prefix = $key === '#default' ? '' : $key;
             $fragment .= ' ' . htmlspecialchars(empty($prefix) ? 'xmlns' : 'xmlns:' . $prefix);
             $fragment .= '="' . htmlspecialchars($xmlns) . '"';
         }
         $fragment .= '>' . $data . '</fragment>';
         $source = new Document();
         if ($source->loadXML($fragment)) {
             foreach ($source->documentElement->childNodes as $child) {
                 $this->appendChild($this->ownerDocument->importNode($child, TRUE));
             }
             return TRUE;
         } else {
             return FALSE;
         }
     }
 }
 /**
  * build out a product link subtree
  *
  * @param DOMDocumentFragment $frag
  * @param string $type
  * @param int $position
  * @param DOMNode $value
  * @return DOMDocumentFragment
  */
 protected function _addProductLink(DOMDocumentFragment $frag, $type, $position, DOMNode $value)
 {
     $frag->appendChild($frag->ownerDocument->createElement('ProductLink'))->addAttributes(array('link_type' => $type, 'operation_type' => 'Add', 'position' => $position))->createChild('LinkToUniqueID')->appendChild($value);
     return $frag;
 }
示例#8
0
 public function setRoot(dom\element $node)
 {
     return parent::appendChild($node);
 }
<?php

$fragment = new DOMDocumentFragment();
$fragment->appendXML();