from schema_lab import run_cases
# 蓝色天空网 mbsky.com:独立输入与逐项预期。
SCENARIOS = [{'id': '1',
'schema': 'schemas/person-reuse.xsd',
'input': '<employee><firstname>蓝</firstname><lastname>天</lastname></employee>',
'expected': True,
'goal': '复用employee'},
{'id': '2',
'schema': 'schemas/person-reuse.xsd',
'input': '<student><firstname>蓝</firstname><lastname>天</lastname></student>',
'expected': True,
'goal': '复用student'},
{'id': '3',
'schema': 'schemas/person-reuse.xsd',
'input': '<member><firstname>蓝</firstname><lastname>天</lastname></member>',
'expected': True,
'goal': '复用member'},
{'id': '4',
'schema': 'schemas/person-extension.xsd',
'input': '<employee><firstname>蓝</firstname><lastname>天</lastname><address>模拟1</address><city>模拟城</city><country>模拟</country></employee>',
'expected': True,
'goal': '追加地址'},
{'id': '5',
'schema': 'schemas/person-extension.xsd',
'input': '<employee><lastname>天</lastname><address>模拟1</address><city>模拟城</city><country>模拟</country></employee>',
'expected': False,
'goal': '继承字段不能缺失'}]
if __name__ == "__main__":
run_cases('schema-complex', SCENARIOS)
本例需在 Windows / Python3.12 / xmlschema4.3.2 XMLSchema10 / elementpath5.1.4;lxml6.1.3+libxml2.11.9交叉观察 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程
运行环境:Windows / Python3.12 / xmlschema4.3.2 XMLSchema10 / elementpath5.1.4;lxml6.1.3+libxml2.11.9交叉观察
入口文件:projects/schema-lab/schema-complex.py
预期结果与验证条件观察提示
- 本章5项主验证结果与逐项预期一致。
- 具体分支:复用employee;复用student;复用member;追加地址;继承字段不能缺失。
- lxml观察可能不同,所有差异保留为处理器限制/后续复核,不能据此升级完整语义或其它处理器。
请结合实际环境逐项观察。
附件与关联工程包下载
课程关联工程包(登记关联24章) · 含当前章节或实例 · mbskycom202611a529.zip