使用PHP和XSD进行XML验证错误


XML validation with PHP and XSD Error

我不会说英语,所以请原谅我。我试图验证一个xml文件与您的xsd使用PHP,但不工作!

首先调用libxml_use_internal_errors(true);获取错误。

然后调用返回false$xmlDomDocument->schemaValidate($pathFileXSD)。所以我得到了libxml_get_errors()函数的误差。

消息错误提示:

Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in the namespace 'http://www.betha.com.br/e-nota-contribuinte-ws/shema/nfse_v01.xsd' are not allowed, since not indicated by an import statement. in file:///C:/v_59/httpdocs/arquivos_imobiliaria/betha/nfse_v01.xsd on line 273

我不明白的消息错误,是一个错误的XSD文件?但这是不可能的,因为XSD是web服务的一部分。谢谢你的帮助。对不起,我说错了。

我使用PHP 5.3.1和libxml2.7.6

XSD文件有错误吗?

Yes and No。代码$xmlDomDocument->schemaValidate($pathFileXSD);在实际加载该文件时存在问题。就这些。这并不意味着xsd文件通常有错误,只是PHP库无法在没有错误的情况下加载它。

但这是不可能的,因为XSD是web服务的一部分。

如您所见,该web服务的XSD文件与PHP中的DOMDocument库不兼容。根据错误信息,联系webservice的技术支持,与他们讨论问题。