| 
<?php
error_reporting(E_ALL);
 
 include 'PEAR.php';
 include 'HV_WDDX_Metadata.php';
 
 $xml_config = implode(file('events.xml'),"\n");     // file holds WDDX metdata.
 $xsl        = implode(file('edit.xsl'),"\n");       // form for editing.
 $xsl_js     = implode(file('javascript.xsl'),"\n"); // for creating javascript array for client-side processing.
 
 // instantiate class. use var_dump for error reporting.
 $data  = new HV_WDDX_Metadata(PEAR_ERROR_CALLBACK, 'var_dump');
 
 // set config
 $data->setConfig($xml_config);
 
 
 // if form has already been submitted, parse request and insert it back into config.
 if (isset($_REQUEST['_action'])) {
 $data->parse($_REQUEST);
 $xml_config = $data->conf;
 }
 
 
 // define arguments for XSLT processor.
 $arguments        = array('/_xml' => $xml_config, '/_xsl' => $xsl, '/_xsl_js' => $xsl_js);
 
 // action for form submission.
 $parameters       = array('action' => $_SERVER["PHP_SELF"]);
 
 $xslt_transformer = xslt_create();
 
 // create javascript array for client-side validation.
 $javascript       = xslt_process($xslt_transformer, 'arg:/_xml', 'arg:/_xsl_js', NULL, $arguments );
 
 // create XUL form markup.
 $xul              = xslt_process($xslt_transformer, 'arg:/_xml', 'arg:/_xsl',    NULL, $arguments, $parameters );
 
 // free object
 xslt_free($xslt_transformer);
 
 
 
 // display form
 header('Content-Type: application/vnd.mozilla.xul+xml');
 echo('<?xml version="1.0" encoding="ISO-8859-15"?>'."\n");
 echo('<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>'."\n");
 echo('<?xml-stylesheet href="xbl.css" type="text/css"?>'."\n");
 ?>
 
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
 xmlns:html="http://www.w3.org/1999/xhtml">
 
 <script type="application/x-javascript" src="validate.js"/>
 
 <script type="application/x-javascript">
 <?php echo $javascript; ?>
 </script>
 
 <?php echo $xul; ?>
 
 </window>
 |