示例#1
0
 public static function validateXML($xmlStr)
 {
     if (SIF_VALIDATE == 'Y' or SIF_VALIDATE == 'W') {
         libxml_use_internal_errors(true);
         $xml = explode("\n", $xmlStr);
         $objDom = new DomDocument();
         if ($xmlStr == '' || $xmlStr == null) {
             ZitLog::writeToErrorLog('[Xml missing in request]', 'Xml is missing in request can not process message', 'Process Message', $_SESSION['ZONE_ID']);
             echo '<FATAL_ERROR>XML FORMAT</FATAL_ERROR>';
             exit;
         }
         if (!$objDom->loadXML($xmlStr)) {
             ZitLog::writeToErrorLog('[Error loading xml to parse]', $xmlStr, 'Process Message', $_SESSION['ZONE_ID']);
             echo '<FATAL_ERROR>XML FORMAT</FATAL_ERROR>';
             exit;
         }
         $schema = $_SESSION['ZONE_VERSION_SCHEMA_DIR'];
         if (!$objDom->schemaValidate($schema)) {
             $errorString = '';
             $allErrors = libxml_get_errors();
             foreach ($allErrors as $error) {
                 $errorString .= SifProcessRequest::Display_xml_error($error, $xml);
             }
             ZitLog::writeToErrorLog("[Error Validating Xml]", "Request Xml:\n{$xmlStr} \n\nSchema Errors:{$errorString}", "Process Message", $_SESSION['ZONE_ID']);
             if (SIF_VALIDATE == 'Y') {
                 return false;
             } else {
                 return true;
             }
         } else {
             return true;
         }
     } else {
         return true;
     }
 }