xml - xsd 模式中的常量键
问题描述
我有以下 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>
推荐阅读
- automated-tests - TestCafe - 如何运行多个夹具(一个接一个,不并发)?
- java - Eclipse 插件:如何查找用户从哪个视图中打开了对话框?
- python - 不能在 Python 中删除空值
- java - 如何使用 JavaFX 从实体中设置 TableView<> 中的值
- git - 合并、变基或分支以获得持久分支?
- laravel - Laravel Controller@update 函数
- c# - 在单独的类/表单中使用引用的 C# 对象
- typo3 - TYPO3 v9.5 站点:语言重定向
- c# - 将字节数组转换为 Json 以通过 REST Api C# 将附件发布到 TFS
- python - 使用 seaborn pairplot 绘制子图