You are here

public function FrxControls::svgDocument in Forena Reports 7.2

Same name and namespace in other branches
  1. 6.2 plugins/FrxControls.inc \FrxControls::svgDocument()

File

plugins/FrxControls.inc, line 217
contains various methods for extending report formating, layout, transformation and design.

Class

FrxControls
@file contains various methods for extending report formating, layout, transformation and design.

Code

public function svgDocument($body, $options) {
  $output = '';
  $doc = new DomDocument();
  $xml_body = '<html><body>' . $body . '</body></html>';
  $doc->formatOutput = FALSE;
  $doc->strictErrorChecking = FALSE;
  $doc
    ->loadXML($xml_body);

  //print($xml_body);
  $xml = simplexml_import_dom($doc);
  $xml
    ->registerXPathNamespace('__empty_ns', 'http://www.w3.org/2000/svg');
  if ($xml) {
    $svg = $xml
      ->xpath('//__empty_ns:svg');
  }
  if ($svg) {
    $output = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>';
    $output .= $svg[0]
      ->asXML();
  }
  return $output;
}