xsd 模式中的常量键
Constant keys in xsd schemas
我有以下 XSD 架构(摘录):
<xs:key name="type">
<xs:selector xpath="./datatypes/struct|./datatypes/array" />
<xs:field xpath="@type" />
</xs:key>
<xs:keyref name="typeref" refer="type">
<xs:selector xpath="./function/parameter|./function/return|./gloabalVariable|./datatypes/struct/field|./datatypes/array" />
<xs:field xpath="@typeref" />
</xs:keyref>
说明:我想指定一些我可以在函数、变量和其他类型中引用的类型。
现在我想参考原始类型,它们没有在XML中声明,但应该是XSD模式中的常量键可以参考
我尝试过的(但不起作用):
<xs:key name="type">
<xs:selector xpath="./datatypes/struct|./datatypes/array" />
<xs:field xpath="@type|'uint8'|'int32'|..." />
</xs:key>
如何在 XSD 模式中指定常量键?
我想到并为我工作的东西:
<xs:simpleType name="type">
<xs:union memberTypes="primitiveType complexType" />
</xs:simpleType>
<xs:simpleType name="primitiveType">
<xs:restriction base="xs:string">
<xs:enumeration value="int8" />
<xs:enumeration value="uint8" />
<xs:enumeration value="int16" />
<xs:enumeration value="uint16" />
<xs:enumeration value="int32" />
<xs:enumeration value="uint32" />
<xs:enumeration value="int64" />
<xs:enumeration value="uint64" />
<xs:enumeration value="double" />
<xs:enumeration value="float" />
<xs:enumeration value="string" />
<xs:enumeration value="bool" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="complexType">
<xs:restriction base="xs:IDREF" />
</xs:simpleType>
我有以下 XSD 架构(摘录):
<xs:key name="type">
<xs:selector xpath="./datatypes/struct|./datatypes/array" />
<xs:field xpath="@type" />
</xs:key>
<xs:keyref name="typeref" refer="type">
<xs:selector xpath="./function/parameter|./function/return|./gloabalVariable|./datatypes/struct/field|./datatypes/array" />
<xs:field xpath="@typeref" />
</xs:keyref>
说明:我想指定一些我可以在函数、变量和其他类型中引用的类型。
现在我想参考原始类型,它们没有在XML中声明,但应该是XSD模式中的常量键可以参考
我尝试过的(但不起作用):
<xs:key name="type">
<xs:selector xpath="./datatypes/struct|./datatypes/array" />
<xs:field xpath="@type|'uint8'|'int32'|..." />
</xs:key>
如何在 XSD 模式中指定常量键?
我想到并为我工作的东西:
<xs:simpleType name="type">
<xs:union memberTypes="primitiveType complexType" />
</xs:simpleType>
<xs:simpleType name="primitiveType">
<xs:restriction base="xs:string">
<xs:enumeration value="int8" />
<xs:enumeration value="uint8" />
<xs:enumeration value="int16" />
<xs:enumeration value="uint16" />
<xs:enumeration value="int32" />
<xs:enumeration value="uint32" />
<xs:enumeration value="int64" />
<xs:enumeration value="uint64" />
<xs:enumeration value="double" />
<xs:enumeration value="float" />
<xs:enumeration value="string" />
<xs:enumeration value="bool" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="complexType">
<xs:restriction base="xs:IDREF" />
</xs:simpleType>