name; $odd = false; switch ($name) { case 'entity' : $odd = new ODDEntity("", "", ""); break; case 'metadata' : $odd = new ODDMetaData("", "", "", ""); break; case 'relationship' : $odd = new ODDRelationship("", "", ""); break; } // Now populate values if ($odd) { // Attributes foreach ($element->attributes as $k => $v) { $odd->setAttribute($k, $v); } // Body $body = $element->content; $a = stripos($body, ""); if (($body) && ($a !== false) && ($b !== false)) { $body = substr($body, $a + 8, $b - ($a + 8)); } $odd->setBody($body); } return $odd; } /** * Import an ODD document. * * @param string $xml The XML ODD. * * @return ODDDocument * @access private */ function ODD_Import($xml) { // Parse XML to an array $elements = xml_to_object($xml); // Sanity check 1, was this actually XML? if ((!$elements) || (!$elements->children)) { return false; } // Create ODDDocument $document = new ODDDocument(); // Itterate through array of elements and construct ODD document $cnt = 0; foreach ($elements->children as $child) { $odd = ODD_factory($child); if ($odd) { $document->addElement($odd); $cnt++; } } // Check that we actually found something if ($cnt == 0) { return false; } return $document; } /** * Export an ODD Document. * * @param ODDDocument $document The Document. * * @return string * @access private */ function ODD_Export(ODDDocument $document) { return "$document"; }