function xml_start_element($parser, $name, $attrs) { switch (strtolower($name)) { case "shortdesc": case "desc": $this->output = null; switch ($this->stack->gettos()) { case "classmeta": case "attribute": case "method": case "signal": case "constructor": $this->flags = $this->flags | DOCMERGER_OUTPUT_ON; } /* -- Fall through -- */ /* -- Fall through -- */ case "classmeta": case "methods": case "method": case "signals": case "signal": case "attributes": case "attribute": case "constructor": $this->stack->push(strtolower($name)); break; case "function": case "signalname": if ($this->stack->gettos() == "method" || $this->stack->gettos() == "signal" || $this->stack->gettos() == "constructor") { $this->stack->push(strtolower($name)); $this->output = null; $this->flags = $this->flags | DOCMERGER_OUTPUT_ON; break; } /* -- Else Fall through -- */ /* -- Else Fall through -- */ default: if ($this->flags & DOCMERGER_OUTPUT_ON) { $this->output .= '<' . strtolower($name) . DocMerger::AttrsToString($attrs) . '>'; } } }
/** * Gets the attributes, data, and children for this element * and all children of this element. * * @access public * @param integer $depth An indent tracker. * @return string The formatted XML. */ function getData($depth = 1) { // Create an XML tag for this element and then // for each child element. If the element name is // a number, then this is cdata. Just add it to the // string. $end = ''; $output = ''; // If this element simply represents character data, // output it. if ($this->name == 'CDATA') { $output = trim($this->data); // Add a new line for the parent closing tag. if (!in_array(strtolower($this->parent->getName()), DocMerger::noNewLine())) { $end .= "\n" . str_pad(' ', $depth - 1, ' ', STR_PAD_LEFT); } } else { // This is more than CDATA. Some extra formatting // will need to be done. // If the parent is character data, add a space before // starting this element. if ($this->parent->getName() == 'CDATA') { $output = ' '; } // Add the element name and attributes. $output .= '<' . strtolower($this->name); $output .= DocMerger::AttrsToString($this->attributes) . '>'; // Some elements should always be followed by a new line. // We should pad the start of the newline to align the // next element properly. if (!in_array(strtolower($this->name), DocMerger::noNewLine())) { $output .= "\n" . str_pad(' ', count($this->children) ? $depth + 1 : $depth, ' ', STR_PAD_LEFT); } // Check to see if we need <![CDATA[ ]]> if (strtolower($this->name) == 'programlisting' || strtolower($this->name) == 'command') { $output .= "<![CDATA[\n"; $end = ']]>' . $end . "\n" . str_pad(' ', $depth, ' ', STR_PAD_LEFT); } // Set up the closing element tag. $end .= '</' . strtolower($this->name) . '>'; // Some elements closing tags should always be followed by // a new line. We should pad the new line again. if (!in_array(strtolower($this->name), DocMerger::noClosingNewLine())) { $end .= "\n" . str_pad(' ', $depth - 1, ' ', STR_PAD_LEFT); } } // Go through the children and get their output. foreach ($this->children as $count => $child) { if ($child->getName() != 'CDATA' && $count > 0) { $output .= ' '; } $output .= $child->getData($depth + 1); } // Return the formatted XML string. return $output . $end; }