我有这个 XML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<vehicle_list>
<vehicle id="v001">
<type registration="ABC-XYZ" year="2010">car</type>
<spent_fuel>8</spent_fuel>
<constructor>XPTO</constructor>
</vehicle>
<vehicle id="v002">
<type>bike</type>
<spent_fuel>0</spent_fuel>
<constructor>XIMA</constructor>
</vehicle>
<vehicle id="v003">
<type>boat</type>
<spent_fuel>40</spent_fuel>
<constructor>AnyBoat</constructor>
</vehicle>
</vehicle_list>
现在我需要(出于学习目的)制作一个 XSD,在其中我使用枚举来限制车辆的类型(汽车、自行车和船)并定义规则,如果类型是“汽车”,那么我需要有两个属性:注册和年份。
我应该如何做到这一点?
我一直在阅读,但找不到任何可以帮助我找到解决方案的东西。
我仅限于 XSD 1.0(不是 XSD 1.1)。