gpt4 book ai didi

python - lxml.etree.relaxng 返回 DocumentInvalid 而不记录错误的原因可能是什么?

转载 作者:太空宇宙 更新时间:2023-11-03 18:58:39 26 4
gpt4 key购买 nike

我的代码如下:

try:
schema = lxml.etree.RelaxNG(file=schema_file)
schema.assertValid(etree)
except lxml.etree.DocumentInvalid as exception:
print(schema.error_log)
print(exception.error_log)
raise exception

它始终引发 DocumentInvalid 错误:

DocumentInvalid: Document does not comply with schema

尚未在架构错误日志或全局错误日志中打印任何错误。

这只发生在某些文件上,其他文件验证正确,或者给出验证失败的原因。 (这是一个很长的架构,所以我不会在这里引用它。)

我什至不知道从哪里开始寻找。可能是什么原因?

最佳答案

这就是您获取错误消息的方式

try:
schema = lxml.etree.RelaxNG(file=schema_file)
schema.assertValid(etree)
except lxml.etree.DocumentInvalid as exception:
print(exception.error_log.filter_from_errors()[0])
raise exception

关于python - lxml.etree.relaxng 返回 DocumentInvalid 而不记录错误的原因可能是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16616011/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com