You are here

public function FrxSVGDoc::render in Forena Reports 7.3

Same name and namespace in other branches
  1. 7.4 docformats/FrxSVGDoc.inc \FrxSVGDoc::render()

Overrides FrxDocument::render

File

docformats/FrxSVGDoc.inc, line 14
FrxSVGDoc Embedded SVG Graph as it's own document. @author davidmetzler

Class

FrxSVGDoc
@file FrxSVGDoc Embedded SVG Graph as it's own document. @author davidmetzler

Code

public function render($r, $format, $options = array()) {
  $output = '';
  $doc = new DomDocument();
  $xml_body = '<html><body>' . $this
    ->check_markup($r->html) . '</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 .= $svg[0]
      ->asXML();
  }
  else {
    $output = '<svg/>';
  }
  return $output;
}