나는 Schematron을 사용하여 문서의 유효성을 검사하려고합니다.SchematronParseError : 스키마 트론 스키마가 잘못되었습니다 (ISOSTS 스키마 용)
나는 schema for ISOSTS standard을 사용합니다.
from lxml import etree
from lxml.isoschematron import Schematron
def validate(self, filename: str):
file = open(filename)
schema_filename = join('/path/to/ISOSTS_validation.sch')
schema_file = open(schema_filename)
# fixme it works. But fails with ISOSTS scheme
# schema_file = StringIO('''\
# <schema xmlns="http://purl.oclc.org/dsdl/schematron" >
# <pattern id="sum_equals_100_percent">
# <title>Sum equals 100%.</title>
# <rule context="Total">
# <assert test="sum(//Percent)=100">Sum is not 100%.</assert>
# </rule>
# </pattern>
# </schema>
# ''')
sct_doc = etree.parse(schema_file)
schematron = Schematron(sct_doc) ## <- FAIL !!!
doc = etree.parse(file)
result = schematron.validate(doc)
file.close()
schema_file.close()
return result
validate('/path/to/feature_doc.xml')
오류 메시지 :
File "/var/www/.../venv/lib/python3.5/site-packages/lxml/isoschematron/__init__.py", line 279, in __init__
schematron_schema_valid.error_log)
lxml.etree.SchematronParseError: invalid schematron schema: <string>:553:0:ERROR:RELAXNGV:RELAXNG_ERR_EXTRACONTENT: Element function has extra content: param
<string>:560:0:ERROR:RELAXNGV:RELAXNG_ERR_ELEMNAME: Expecting element schema, got variable
<string>:0:0:ERROR:RELAXNGV:RELAXNG_ERR_INTEREXTRA: Extra element function in interleave
<string>:42:0:ERROR:RELAXNGV:RELAXNG_ERR_CONTENTVALID: Element schema failed to validate content
가 어떻게 수리를?