1
XSD 파일에 대해 XML의 유효성을 검사하고 오류가 있으면 가져오고 싶습니다.오류가있는 XSD에 대해 XML 유효성을 확인하십시오.
DOM에서는 사용하지만 XMLReader에서는 사용하면 정상적으로 작동합니다. 지금까지 두 가지 모두 libxml 라이브러리를 사용하고 있으므로 XMLReader 용으로 사용해 보려고했지만 행운은 없었습니다.
감사
DOM 스키마를 설정 한 후
libxml_use_internal_errors(true);
if (! $xml->schemaValidate($xsd_file))
{
get_errors();
exit;
}
function get_errors()
{
$messages = null;
$errors = libxml_get_errors();
foreach ($errors as $error)
{
switch ($error->level)
{
case LIBXML_ERR_ERROR:
$messages .= 'Error ' . $error->code . $error->message;
break;
case LIBXML_ERR_WARNING:
$messages .= 'Warning ' . $error->code . $error->message;
break;
case LIBXML_ERR_FATAL:
$messages .= 'Fatal ' . $error->code . $error->message;
break;
}
echo $messages .= ($error->file) ? $error->file : $error->line;
}
}
는 XmlReader를
libxml_use_internal_errors(true);
//This returns true all times whether XML has faults or not
if (! $reader->setSchema($xsd_file))
{
//This echos nothing whether XML has faults or not
get_errors();
}
문제는 XML, XSD, 파서 등에서 매우 새로운 점입니다. 모든 문서를 읽었지만 문제가 해결되지 않았습니다. isValid() 다른 함수를 함께 넣으려고했으나 아무 것도 변경되지 않았습니다. 그것도 봤 거든. 나는 더 많은 경험이나 도움이 필요하다고 생각합니다. – BentCoder