0
只是要简明扼要我想获得这样的事:如何在XML Schema中定义具有相同名称但不同类型的元素序列?
<root>
<field value="..." text="...">fixed_value1</field>
<field value="..." text="...">fixed_value2</field>
<field value="..." text="...">fixed_value3</field>
<!-- in some cases we can choose the «fixed_value» among different ones -->
...
<field value="..." text="...">fixed_valueN</field>
</root>
我尝试不同的方法,但它似乎很不可能才达到,因为XML模式不允许设置的元素列表名称相同,但不同的类型(简单或复杂并不重要...)。这样对吗?没有其他方法来定义像上面那样的结构?
编辑:也许我必须解释它好一点。在元素«field»的打开和关闭标记之间必须有一个由XML Schema定义的值(换句话说,对于用户来说,不可能写入与fixed_value不同的东西)。又如:
<root>
<field value="Ferrari" text="company">Car</field>
<!-- but it could be Van or Motorcycle or Plane -->
<field value="12300000" text="euro">Cost</field>
<!-- here instead it's only possible to choose «Cost» -->
<field value="Red" text="">Color</field>
<!-- same as above -->
</root>
这可能吗?提前致谢!