Location: PHPKode > projects > Mocovie web framework > mocovi/definitions/validateControl.php
<?php
$startElement = 'content';
require_once('createControlMaster.php');
echo $relaxNG->saveXML();
require_once('../../settings.php');
require_once($GLOBALS['filesystemsLibrary'].'XMLFS.php');
$newControlName = 'paragraph';
libxml_use_internal_errors(true);

$fs = new XMLFS($GLOBALS['filesystems'].'mocovi.de.xml');
$model = $fs->getModel('/home/');
$control = new DomDocument('1.0', 'utf-8');
$control->appendChild($control->importNode($fs->xpath->query('//mocovi:content[1]', $model)->item(0)));
$control->firstChild->appendChild($new = $control->createElement($newControlName));
//echo $new->getLineNo(); // Will be needed to verify the corresponding line of the error.
if($result = @$control->relaxNGValidateSource($relaxNG->saveXML()))
	echo 'Works fine';
else
	echo 'Failure';

function libxml_display_error($error)
{
	$return = "<br/>\n";
	switch ($error->level)
	{
		case LIBXML_ERR_WARNING:
			$return .= "<b>Warning $error->code</b>: ";
			break;
		case LIBXML_ERR_ERROR:
			$return .= "<b>Error $error->code</b>: ";
			break;
		case LIBXML_ERR_FATAL:
			$return .= "<b>Fatal Error $error->code</b>: ";
			break;
	}
	$return .= trim($error->message);
	if ($error->file)
		$return .= " in <b>$error->file</b>";
	$return .= " on line <b>$error->line</b>\n";
	return $return;
}

function libxml_display_errors()
{
	$errors = libxml_get_errors();
	foreach ($errors as $error)
	print libxml_display_error($error);
	libxml_clear_errors();
}
libxml_display_errors();
echo $result;
Return current item: Mocovie web framework