Generates a XML helper instance.
public createXmlHelper ( DOMDocument $xmldoc ) : Horde_Kolab_Format_Xml_Helper | ||
$xmldoc | DOMDocument | The XML document the helper works with. |
return | Horde_Kolab_Format_Xml_Helper | The helper utility. |
protected function getXmlType($type, $previous = null, $kolab_type = 'kolab', $version = '1.0') { $factory = new Horde_Kolab_Format_Factory(); $doc = new DOMDocument('1.0', 'UTF-8'); if ($previous !== null) { $doc->loadXML($previous); $helper = $factory->createXmlHelper($doc); $root_node = $helper->findNode('/' . $kolab_type); } else { $helper = $factory->createXmlHelper($doc); $root_node = $helper->createNewNode($doc, $kolab_type); $root_node->setAttribute('version', $version); } $type = $factory->createXmlType($type); return array($helper, $root_node, $type); }
protected function getXmlType($type, $previous = null, $kolab_type = 'kolab', $version = '1.0') { $factory = new Horde_Kolab_Format_Factory(); $doc = new DOMDocument('1.0', 'UTF-8'); if ($previous !== null) { $doc->loadXML($previous); } $helper = $factory->createXmlHelper($doc); $type = $factory->createXmlType($type); return array($helper, $doc, $type); }
/** * Convert the data to a XML stream. Strings contained in the data array may * only be provided as UTF-8 data. * * @param array $object The data array representing the object. * @param array $options Additional options when writing the XML. * <pre> * - previous: The previous XML text (default: empty string) * - relaxed: Relaxed error checking (default: false) * </pre> * * @return string The data as an XML string. * * @throws Horde_Kolab_Format_Exception If converting the data to XML failed. */ public function save($object, $options = array()) { if (!isset($options['previous'])) { $this->_xmldoc = $this->_getParser()->getDocument(); } else { $parse_options = $options; unset($parse_options['previous']); $this->_xmldoc = $this->_getParser()->parse($options['previous'], $parse_options); } $this->_refreshParser(); $params = $this->_getParameters($options); $this->_getRoot($params)->save($this->_root_name, $object, $this->_xmldoc, $this->_factory->createXmlHelper($this->_xmldoc), $params); return $this->_xmldoc->saveXML(); }