Compiler: clearer reporting on XML format issues + additional validation by the mean of an XSD (same reporting chanel). The validation provided by the XSD is not strict, but this is a good starting point.

SVN:trunk[1952]
This commit is contained in:
Romain Quetiez
2012-04-11 14:54:51 +00:00
parent 11c85d7710
commit 6826e132a8
2 changed files with 527 additions and 2 deletions

View File

@@ -277,7 +277,8 @@ class ModelFactory
static protected $aLoadedMenus;
static protected $aWellKnownParents = array('DBObject', 'CMDBObject','cmdbAbstractObject');
static protected $aLoadedModules;
static protected $aLoadErrors;
public function __construct($sRootDir)
{
@@ -292,6 +293,9 @@ class ModelFactory
self::$aLoadedClasses = array();
self::$aLoadedMenus = array();
self::$aLoadedModules = array();
self::$aLoadErrors = array();
libxml_use_internal_errors(true);
}
public function Dump($oNode = null)
@@ -315,7 +319,15 @@ class ModelFactory
foreach($aDataModels as $sXmlFile)
{
$oDocument = new DOMDocument('1.0', 'UTF-8');
libxml_clear_errors();
$oDocument->load($sXmlFile, LIBXML_NOBLANKS);
$bValidated = $oDocument->schemaValidate(APPROOT.'setup/itop_design.xsd');
$aErrors = libxml_get_errors();
if (count($aErrors) > 0)
{
self::$aLoadErrors[$sModuleName] = $aErrors;
}
$oXPath = new DOMXPath($oDocument);
$oNodeList = $oXPath->query('//*');
foreach($oNodeList as $oNode)
@@ -410,7 +422,19 @@ class ModelFactory
}
}
}
/**
* XML load errors (XML format and validation)
*/
function HasLoadErrors()
{
return (count(self::$aLoadErrors) > 0);
}
function GetLoadErrors()
{
return self::$aLoadErrors;
}
function GetLoadedModules($bExcludeWorkspace = true)
{
if ($bExcludeWorkspace)