示例#1
0
 public static function parse($file, $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">')
 {
     $tpl = new PXHTMLTemplate();
     $xml = '<' . '?xml version="1.0"?' . '>';
     $root_regex = '/<\\/?pxhtml:root.*?>/';
     return str_replace($xml, $doctype, preg_replace($root_regex, '', PXHTMLTemplate::php()->apply($tpl->parse($file)->saveXML())));
 }
示例#2
0
 public function handleMatch($node)
 {
     $PXHTMLTemplate = new PXHTMLTemplate();
     $xtn = $node->getAttribute('xtn') ? '.' . $node->getAttribute('xtn') : '.php';
     $cdata = $node->getAttribute('cdata') ? $node->getAttribute('cdata') : FALSE;
     $dom = $PXHTMLTemplate->parse(chip($node->getAttribute('file'))->getFilePath() . $xtn, TRUE, $cdata);
     // collect all things under the PXHTML root in new_dom, and
     // attach them as an appendChild statement
     $xpath = new DOMXPath($dom);
     $results = $xpath->query('/pxhtml:root');
     $results = $results->item(0)->firstChild;
     // transfer all of the nodes from the include into the document at the include point
     while ($results) {
         $new_node = $this->importNode($results);
         $node->parentNode->insertBefore($new_node, $node);
         $results = $results->nextSibling;
     }
     $node->parentNode->removeChild($node);
 }