You are here

private function FrxReport::_check_xml_node_empty in Forena Reports 7.3

Returns true if a node has no children, no attributes (or empty values in it's attributes), and no text content

1 call to FrxReport::_check_xml_node_empty()
FrxReport::render_section in ./FrxReport.inc
Recursive report renderer Walks the nodes rendering the report.

File

./FrxReport.inc, line 743
Basic report provider. Controls the rendering of the report.

Class

FrxReport

Code

private function _check_xml_node_empty($node) {
  if (!count($node
    ->children())) {
    $empty_attributes = false;
    if (count($node
      ->attributes()) > 0) {
      foreach ($node
        ->attributes() as $attr => $attr_val) {
        $num_total_attr = 0;
        $num_empty_attr = 0;
        $attr_val = (string) $attr_val;
        if ($attr_val == "") {
          ++$num_empty_attr;

          //return '';
        }
        ++$num_total_attr;
      }
      if ($num_total_attr == $num_empty_attr) {
        $empty_attributes = true;
      }
    }
    else {
      $empty_attributes = true;
    }
    if ($empty_attributes) {
      $node_text = dom_import_simplexml($node)->textContent;
      if ($node_text == "") {

        // empty xml element
        return true;
      }
    }
  }
  return false;
}