XML Schema:具有仅包含文本的属性的元素? [英] XML Schema: Element with attributes containing only text?
本文介绍了XML Schema:具有仅包含文本的属性的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我很难找到这个.如何在 XML 模式文件中为 XML 定义一个元素,如下所示:
I'm having difficulty searching for this. How would I define an element in an XML schema file for XML that looks like this:
<option value="test">sometext</option>
我不知道如何定义类型为 xs:string
并且还具有属性的元素.
I can't figure out how to define an element that is of type xs:string
and also has an attribute.
这是我目前所得到的:
<xs:element name="option">
<xs:complexType>
<xs:attribute name="value" type="xs:string" />
</xs:complexType>
</xs:element>
推荐答案
试试
<xs:element name="option" type="AttrElement" />
<xs:complexType name="AttrElement">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="value" type="xs:string">
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
这篇关于XML Schema:具有仅包含文本的属性的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文