DB Designer 4 TO Propel Schema Converter
By Jonathan Graham
- Last Update: 14 November 2006
NOTE: As of 11/14/2006, dbd2propel has been added to the
Propel repository. This conversion
page now uses the latest version of the xsl file from the repository.
Comments
Here is the php code.
PHP Code
Here is the code that processes the DB Designer xml... of course this could be streamlined
if one were using PHP 5.
<?
function transform() {
if ( !isset($_REQUEST["xml"]) ) {
echo "<h3>Must enter an XML string!</h3>";
return;
}
$xmlstr = stripslashes($_REQUEST["xml"]);
$xml = new DomDocument; // from /ext/dom
$xml->loadXML($xmlstr);
$xsl = new DomDocument;
$xsl->load("http://propel.phpdb.org/trac/browser/trunk/contrib/dbd2propel/dbd2propel.xsl?format=txt");
// Was:
// $xsl->load("dbd2propel.xsl");
$proc = new xsltprocessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
$xmlstr = $proc->transformToXML($xml);
echo "<strong>Propel Schema XML:</strong>";
echo "<hr><pre style=\"font-size:9pt\">";
echo htmlentities($xmlstr);
echo "</pre><hr>";
}
?>