当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XSD 混合内容的复合类型
A mixed complex type element can contain attributes, elements, and text.
XSD混合内容的复合类型元素可以包含属性、元素和文本。
An XML element, "letter", that contains both text and other elements:
一个XML元素,"letter"既可以包含文本又可以包含其它元素:
<letter> |
The following schema declares the "letter" element:
下面的XML Schema声明了"letter"元素:
<xs:element name="letter"> |
Note: To enable character data to appear between the child-elements of "letter", the mixed attribute must be set to "true". The <xs:sequence> tag means that the elements defined (name, orderid and shipdate) must appear in that order inside a "letter" element.
注意:为了使字符数据能出现在"letter"子元素之间,mixed 属性必须设置为"true"。<xs:sequence>标签指定了已定义的元素(name、orderid 和 shipdate)在"letter"元素中必须以指定的顺序出现。
We could also give the complexType element a name, and let the "letter" element have a type attribute that refers to the name of the complexType (if you use this method, several elements can refer to the same complex type):
我们可以为这个complexType元素定义一个名称,并且让"letter"元素包含一个引用了complexType名称的类型属性(如果你使用了上述方法,几个元素可以同时引用相同的复合类型):
<xs:element name="letter" type="lettertype"/> <xs:complexType name="lettertype" mixed="true"> |