xml - 类型属性的 XSD 问题:类型属性不能与 simpleType 或 complexType 一起出现
问题描述
我已经在 stackoverflow 上寻找了答案,但不幸的是,所有的分析器都不适合我:
我有以下xml:
<STGDocument version="3" workitem-id="0" index="1">
<ID type="String">ab78e02c-a472-45b9-99d0-57c19034a51b</ID>
....
以及从网页生成的 XSD:
<xs:element name="STGDocument">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:string">
<xs:complexType>
<xs:attribute name="type" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
.......
不知何故,<xs:element name "Id" ....>
标签抛出错误“类型属性不能与 simpleType 或 complexType 一起出现”
我怎样才能解决这个问题?
如前所述,我在 SOF 上尝试了所有解决方案,但没有一个对我有用......
纳克斯
解决方案
元素的类型要么使用type
属性(如type="xs:string"
)声明,要么使用嵌套xs:simpleType
或xs:complexType
元素声明。你不能两者兼得,这就是它抱怨的原因。
您的 ID 元素的实际类型是“具有简单内容的复杂类型”,应按以下示例声明:XSD : How to use both value and attribute
推荐阅读
- modal-dialog - 如何将输入值传递给松弛螺栓框架中模态的下一个视图?
- r - R kable linebreak 切断条纹颜色
- visual-studio-code - 视觉工作室代码建议转义
- authentication - Cakephp 认证结果仅在无状态验证时无效
- firebase - Firebase“实时数据库”和“Cloud Firestore”在 REST API 和身份验证方面的区别
- javascript - 添加时不出现滚动条
- 由jquery动态
- mysql - UNION ALL 具有不同的列数并创建 Nulls MySQL
- mysql - 查询随机排序记录
- mysql - MySQL、HiveQL、SQL:组合集合
- graph-theory - 图编辑距离(GED)和(非)同构图