XSD(XML Schema Define)中一个复杂的纯文本元素可以包含文本和属性。
-------------------------------------------------- ------------------------------
复合纯文本元素
这种类型只包含简单的内容(文本和属性),所以我们可以先添加一个xs:simpleContent元素,接着在xs:simpleContent中定义xs:extension或者xs:restriction。
如下:
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
<
xs:element
name
="somename"
>
< xs:complexType >
< xs:simpleContent >
< xs:extension base ="basetype" >
....
....
</ xs:extension >
</ xs:simpleContent >
</ xs:complexType >
</ xs:element >
< xs:complexType >
< xs:simpleContent >
< xs:extension base ="basetype" >
....
....
</ xs:extension >
</ xs:simpleContent >
</ xs:complexType >
</ xs:element >
OR
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
<
xs:element
name
="somename"
>
< xs:complexType >
< xs:simpleContent >
< xs:restriction base ="basetype" >
....
....
</ xs:restriction >
</ xs:simpleContent >
</ xs:complexType >
</ xs:element >
< xs:complexType >
< xs:simpleContent >
< xs:restriction base ="basetype" >
....
....
</ xs:restriction >
</ xs:simpleContent >
</ xs:complexType >
</ xs:element >
实例:
<
shoesize
country
="france"
>
35
</
shoesize
>
xsd:
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
<
xs:element
name
="shoesize"
>
< xs:complexType >
< xs:simpleContent >
< xs:extension base ="xs:integer" >
< xs:attribute name ="country" type ="xs:string" />
</ xs:extension >
</ xs:simpleContent >
</ xs:complexType >
</ xs:element >
< xs:complexType >
< xs:simpleContent >
< xs:extension base ="xs:integer" >
< xs:attribute name ="country" type ="xs:string" />
</ xs:extension >
</ xs:simpleContent >
</ xs:complexType >
</ xs:element >