from schema_lab import run_cases
# 蓝色天空网 mbsky.com:独立输入与逐项预期。
SCENARIOS = [{'id': '1',
'schema': 'schemas/order-inline.xsd',
'input': '<shiporder '
'orderid="123456"><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><address>模拟1</address><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>1</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': True,
'goal': '两条商品可选note'},
{'id': '2',
'schema': 'schemas/order-inline.xsd',
'input': '<shiporder '
'><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><address>模拟1</address><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>1</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': False,
'goal': '缺orderid'},
{'id': '3',
'schema': 'schemas/order-inline.xsd',
'input': '<shiporder '
'orderid="123456"><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><address>模拟1</address><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>0</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': False,
'goal': '数量0'},
{'id': '4',
'schema': 'schemas/order-inline.xsd',
'input': '<shiporder '
'orderid="123456"><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>1</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': False,
'goal': '缺地址'},
{'id': '5',
'schema': 'schemas/order-inline.xsd',
'input': '<shiporder '
'orderid="letters"><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><address>模拟1</address><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>1</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': True,
'goal': '六位模式仅命名方案增加'},
{'id': '6',
'schema': 'schemas/order-ref.xsd',
'input': '<shiporder '
'orderid="123456"><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><address>模拟1</address><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>1</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': True,
'goal': '两条商品可选note'},
{'id': '7',
'schema': 'schemas/order-ref.xsd',
'input': '<shiporder '
'><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><address>模拟1</address><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>1</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': False,
'goal': '缺orderid'},
{'id': '8',
'schema': 'schemas/order-ref.xsd',
'input': '<shiporder '
'orderid="123456"><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><address>模拟1</address><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>0</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': False,
'goal': '数量0'},
{'id': '9',
'schema': 'schemas/order-ref.xsd',
'input': '<shiporder '
'orderid="123456"><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>1</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': False,
'goal': '缺地址'},
{'id': '10',
'schema': 'schemas/order-ref.xsd',
'input': '<shiporder '
'orderid="letters"><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><address>模拟1</address><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>1</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': True,
'goal': '六位模式仅命名方案增加'},
{'id': '11',
'schema': 'schemas/order-named.xsd',
'input': '<shiporder '
'orderid="123456"><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><address>模拟1</address><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>1</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': True,
'goal': '两条商品可选note'},
{'id': '12',
'schema': 'schemas/order-named.xsd',
'input': '<shiporder '
'><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><address>模拟1</address><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>1</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': False,
'goal': '缺orderid'},
{'id': '13',
'schema': 'schemas/order-named.xsd',
'input': '<shiporder '
'orderid="123456"><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><address>模拟1</address><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>0</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': False,
'goal': '数量0'},
{'id': '14',
'schema': 'schemas/order-named.xsd',
'input': '<shiporder '
'orderid="123456"><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>1</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': False,
'goal': '缺地址'},
{'id': '15',
'schema': 'schemas/order-named.xsd',
'input': '<shiporder '
'orderid="letters"><orderperson>蓝色天空网</orderperson><shipto><name>学习者</name><address>模拟1</address><city>模拟城</city><country>模拟</country></shipto><item><title>HTML课程</title><note>自有模拟商品</note><quantity>1</quantity><price>10.90</price></item><item><title>CSS课程</title><quantity>2</quantity><price>9.90</price></item></shiporder>',
'expected': False,
'goal': '六位模式仅命名方案增加'}]
if __name__ == "__main__":
run_cases('schema-example', 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-example.py
预期结果与验证条件观察提示
- 本章15项主验证结果与逐项预期一致。
- 具体分支:两条商品可选note;缺orderid;数量0;缺地址;六位模式仅命名方案增加;两条商品可选note;缺orderid;其余分支逐项列于清单与源码。
- lxml观察可能不同,所有差异保留为处理器限制/后续复核,不能据此升级完整语义或其它处理器。
请结合实际环境逐项观察。
附件与关联工程包下载
课程关联工程包(登记关联24章) · 含当前章节或实例 · mbskycom202611a529.zip