1

私は次のようなコードを持っています:

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

ただし、スキーマ エラー ログにもグローバル エラー ログにもエラーは出力されません。

これは一部のファイルでのみ発生し、他のファイルは正しく検証されるか、検証に失敗した理由が示されます。(非常に長いスキーマなので、ここでは引用しません。)

どこから探し始めればいいのかもわかりません。考えられる原因は何ですか?

4

1 に答える 1

1

それがエラーメッセージを取得する方法です

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
于 2015-04-17T05:04:23.247 に答える