function libxml_display_all_errors() { $errors = libxml_get_errors(); $codes = array(); print "<table id='errors' class='table-striped'><thead><th>Line</th><th>Severity and code</th><th>Message</th></thead><tbody>"; $i = 1; if ($i % 2 == 0) { $class = 'even'; } else { $class = 'odd'; } foreach ($errors as $error) { $code = $error->code; //if (!in_array($code,$codes)) { $codes[] = $code; if ($i % 2 == 0) { $class = 'even'; } else { $class = 'odd'; } $i++; print libxml_display_error($error, $class); //} } print "</tbody></table>"; if (isset($extra_message)) { echo '<br/><div class="alert alert-error">' . $extra_message . '</div>'; } libxml_clear_errors(); }
/** * Gestiona errores de validación XML */ function libxml_display_errors() { $errors = libxml_get_errors(); foreach ($errors as $error) { print libxml_display_error($error); } libxml_clear_errors(); }
function libxml_display_errors() { global $status; $errors = libxml_get_errors(); foreach ($errors as $error) { $status .= libxml_display_error($error) . "<br />\n"; } libxml_clear_errors(); }
function libxml_display_errors() { $errors = libxml_get_errors(); $x = ""; foreach ($errors as $error) { $x = $x . libxml_display_error($error); } return $x; libxml_clear_errors(); }
function libxml_display_errors() { $error_message = ""; $errors = libxml_get_errors(); foreach ($errors as $error) { $error_message = $error_message . "\n" . libxml_display_error($error) . "\n"; } libxml_clear_errors(); return $error_message; }
function libxml_display_errors() { $errors = libxml_get_errors(); $messages = ""; foreach ($errors as $error) { $messages .= libxml_display_error($error); break; //return only the first error message. if you remove this, then all errors are returned. } return $messages; libxml_clear_errors(); }
function libxml_display_errors() { $errors = libxml_get_errors(); foreach ($errors as $error) { if ($error->code != 1872) { // Array delle linee in cui di presenta l'errore $errArray[] = $error->line; print libxml_display_error($error); } } libxml_clear_errors(); return $errArray; }
function libxml_error_message($delim = "\n") { $errors = libxml_get_errors(); $retval = ""; foreach ($errors as $error) { if ($retval != "") { $retval .= $delim; } $retval .= libxml_display_error($error); } libxml_clear_errors(); return $retval; }
function validateAgainstXsd() { print "Start validation against xsd\n"; $xml = new DOMDocument(); $xml->load($this->_xml); if (!$xml->schemaValidate($this->_xsd)) { $errors = libxml_get_errors(); foreach ($errors as $error) { print libxml_display_error($error); } libxml_clear_errors(); } else { print "validation successful\n"; } }
/** * Validate all the XML in the package, including checking XSDs, missing data. * @param string the path of the directory that contains all the package files * @return boolean true if every file exists in the manifest, * false if any is missing. */ function checkResources($import_path) { global $items, $msg, $skip_ims_validation, $avail_dt; if (!is_dir($import_path)) { return; } //if the package has access for all content, skip validation for now. //todo: import the XSD into our validator if ($skip_ims_validation) { return true; } //generate a file tree $data = rscandir($import_path); //check if every file is presented in the manifest foreach ($data as $filepath) { $filepath = substr($filepath, strlen($import_path)); //validate xml via its xsd/dtds if (preg_match('/(.*)\\.xml/', $filepath)) { libxml_use_internal_errors(true); $dom = new DOMDocument(); $dom->load(realpath($import_path . $filepath)); if (!@$dom->schemaValidate('main.xsd')) { $errors = libxml_get_errors(); foreach ($errors as $error) { //suppress warnings if ($error->level == LIBXML_ERR_WARNING) { continue; } $msg->addError(array('IMPORT_CARTRIDGE_FAILED', libxml_display_error($error))); } libxml_clear_errors(); } //if this is the manifest file, we do not have //to check for its existance. // if (preg_match('/(.*)imsmanifest\.xml/', $filepath)){ // continue; // } } } //Create an array that mimics the structure of the data array, //based on the xml items $filearray = array(); foreach ($items as $name => $fileinfo) { if (isset($fileinfo['file']) && is_array($fileinfo['file']) && !empty($fileinfo['file'])) { foreach ($fileinfo['file'] as $fn) { if (!in_array(realpath($import_path . $fn), $filearray)) { //if url, skip if (preg_match('/^http[s]?\\:/', $fn) == 0) { $filearray[] = realpath($import_path . $fn); } } } } //validate the xml by its schema if (preg_match('/imsqti\\_(.*)/', $fileinfo['type'])) { $qti = new QTIParser($fileinfo['type']); $xml_content = @file_get_contents($import_path . $fileinfo['href']); $qti->parse($xml_content); //will add error to $msg if failed } //add all dependent discussion tools to a list if (isset($fileinfo['dependency']) && !empty($fileinfo['dependency'])) { $avail_dt = array_merge($avail_dt, $fileinfo['dependency']); } } //check if all files in the xml is presented in the archieve $result = array_diff($filearray, $data); //using sizeof because array_diff only //returns an array containing all the entries from array1 that //are not present in any of the //other arrays. //Using sizeof make sure it's not a subset of array2. //-1 on data because it always contain the imsmanifest.xml file if (!$skip_ims_validation) { if (!empty($result) || sizeof($data) - 1 > sizeof($filearray)) { $msg->addError(array('IMPORT_CARTRIDGE_FAILED', _AT('ims_missing_references'))); } } return true; }
function libxml_display_errors($display_errors = true) { $errors = libxml_get_errors(); $chain_errors = ""; foreach ($errors as $error) { $chain_errors .= preg_replace('/( in\\ \\/(.*))/', », strip_tags(libxml_display_error($error))) . "\n"; if ($display_errors) { trigger_error(libxml_display_error($error), E_USER_WARNING); } } libxml_clear_errors(); return $chain_errors; }
echo '</body></html>'; exit; } } $lines = file($conffile); $dom->load($conffile); if ($dom->schemaValidate('visu_config.xsd')) { print "config <b>" . $conffile . " is valid </b> XML<br/>"; checkVersion($dom); } else { print "config <b>" . $conffile . " is NOT </b> valid XML"; checkVersion($dom); echo '<hr />'; $errors = libxml_get_errors(); foreach ($errors as $error) { echo libxml_display_error($error); } libxml_clear_errors(); } echo '<hr />'; echo '<pre>'; foreach ($lines as $line_num => $line) { $error_in_line = in_array($line_num + 1, $error_array); if ($error_in_line) { echo '<b>'; } printf('<a name="%s">%4d</a>: ', $line_num, $line_num + 1); echo xml_highlight($line); if ($error_in_line) { echo '</b>'; }
function libxml_display_errors() { $errorString = ''; $errors = libxml_get_errors(); foreach ($errors as $error) { $errorString .= libxml_display_error($error); } libxml_clear_errors(); return $errorString; }
function libxml_display_errors($msg) { $errors = libxml_get_errors(); //die ('Errors = ' . print_r($errors)); foreach ($errors as $error) { $msg .= libxml_display_error($error) . "<br />\n"; } libxml_clear_errors(); return $msg; }
$decvar->addAttribute("minvalue", "0"); $decvar->addAttribute("varname", "SCORE"); $decvar->addAttribute("vartype", "Decimal"); $respcondition = $resprocessing->addChild("respcondition"); $respcondition->addAttribute("continue", "No"); $conditionvar = $respcondition->addChild("conditionvar"); $other = $conditionvar->addChild("other"); continue; // XXX } } $DOM = new DOMDocument('1.0'); $DOM->preserveWhiteSpace = false; $DOM->formatOutput = true; $DOM->loadXML($QTI->asXML()); echo "\nValidating (may take a few seconds)...\n"; libxml_use_internal_errors(true); if (isset($_SESSION['novalidate'])) { echo "\nContent validation bypassed...\n"; } else { if (!$DOM->schemaValidate('xml/ims_qtiasiv1p2p1.xsd')) { echo "\nWarning: Quiz XML Not Valid\n"; $errors = libxml_get_errors(); foreach ($errors as $error) { echo "Error:", libxml_display_error($error), "\n"; } libxml_clear_errors(); } else { echo "\nQuiz XML validated\n"; } }