当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XSD 复合纯文本
A complex text-only element can contain text and attributes.
一个复合纯文本元素可以包含文本和属性。
This type contains only simple content (text and attributes), therefore we add a simpleContent element around the content. When using simple content, you must define an extension OR a restriction within the simpleContent element, like this:
这种类型只包含简单的内容(文本和属性),因此,我们需要在内容周围添加一个simpleContent元素;当使用简单内容时,你必须在simpleContent元素中定义一个扩展 [ extension ] 或约束 [ restriction ],如下所示:
<xs:element name="somename"> OR <xs:element name="somename"> |
Tip: Use the extension/restriction element to expand or to limit the base simple type for the element.
提示:可以使用 extension / restriction 元素来扩展或约束元素的基本简单类型。
Here is an example of an XML element, "shoesize", that contains text-only:
下面列举了一个只包含文本的XML元素"shoesize":
<shoesize country="france">35</shoesize> |
The following example declares a complexType, "shoesize". The content is defined as an integer value, and the "shoesize" element also contains an attribute named "country":
下述案例声明了一个复合类型元素"shoesize"。其内容定义为整数值,"shoesize"元素包含了名为"country"的属性:
<xs:element name="shoesize"> |
We could also give the complexType element a name, and let the "shoesize" 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元素定义一个名称,让"shoesize"元素包含种类属性。种类属性的名称就是complexType元素的名称(如果你用上述方法,几个元素可以引用相同的复合类型):
<xs:element name="shoesize" type="shoetype"/> <xs:complexType name="shoetype"> |