from schema_lab import run_cases
# 蓝色天空网 mbsky.com:独立输入与逐项预期。
SCENARIOS = [{'id': '1',
'schema': 'schemas/simplecontent-extension.xsd',
'input': '<shoe country="模拟">35</shoe>',
'expected': True,
'goal': '整数简单内容+必需属性'},
{'id': '2',
'schema': 'schemas/simplecontent-extension.xsd',
'input': '<shoe country="模拟">35.5</shoe>',
'expected': False,
'goal': '整数简单内容+必需属性'},
{'id': '3',
'schema': 'schemas/simplecontent-extension.xsd',
'input': '<shoe>35</shoe>',
'expected': False,
'goal': '整数简单内容+必需属性'},
{'id': '4',
'schema': 'schemas/simplecontent-extension.xsd',
'input': '<shoe country="模拟"><value>35</value></shoe>',
'expected': False,
'goal': '整数简单内容+必需属性'},
{'id': '5',
'schema': 'schemas/simplecontent-restriction.xsd',
'input': '<shoe country="模拟">30</shoe>',
'expected': True,
'goal': '简单内容restriction边界'},
{'id': '6',
'schema': 'schemas/simplecontent-restriction.xsd',
'input': '<shoe country="模拟">45</shoe>',
'expected': True,
'goal': '简单内容restriction边界'},
{'id': '7',
'schema': 'schemas/simplecontent-restriction.xsd',
'input': '<shoe country="模拟">29</shoe>',
'expected': False,
'goal': '简单内容restriction边界'},
{'id': '8',
'schema': 'schemas/simplecontent-restriction.xsd',
'input': '<shoe country="模拟">46</shoe>',
'expected': False,
'goal': '简单内容restriction边界'}]
if __name__ == "__main__":
run_cases('schema-complex-text', 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-text.py
预期结果与验证条件观察提示
- 本章8项主验证结果与逐项预期一致。
- 具体分支:整数简单内容+必需属性;整数简单内容+必需属性;整数简单内容+必需属性;整数简单内容+必需属性;简单内容restriction边界;简单内容restriction边界;简单内容restriction边界;其余分支逐项列于清单与源码。
- lxml观察可能不同,所有差异保留为处理器限制/后续复核,不能据此升级完整语义或其它处理器。
请结合实际环境逐项观察。
附件与关联工程包下载
课程关联工程包(登记关联24章) · 含当前章节或实例 · mbskycom202611a529.zip