|
中华网络安全联盟 作者:佚名 来源:网络转载 时间:2006-3-20
<xsd:attribute name="currency" type="xsd:string"/> <xsd:attribute name="value"?type="xsd:decimal"/> </xsd:complexContent> </xsd:element> 第三种类型: <xsd:element name="letterBody"> <xsd:complexType mixed="true"> <xsd:sequence> <xsd:element name="salutation"> <xsd:complexType mixed="true"> <xsd:sequence> <xsd:element name="name" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="quantity"type="xsd:positiveInteger"/> <xsd:element name="productName" type="xsd:string"/> <xsd:element name="shipDate"type="xsd:date" minOccurs="0"/> </xsd:sequence> </xsd:complexType> </xsd:element> 第三种类型的实例可能如下: <letterBody> <salutation>Dear Mr.<name>Robert Smith</name>.</salutation> Your order of <quantity>1</quantity> <productName>Baby Monitor</productName> shipped from our warehouse on <shipDate>1999-05-21</shipDate> </letterBody> 12、根据11的描述那么要定义一个空内容的元素,也就是说定义一个只包含属性的元素,只要在complexContent中不包含任何子元素,就可以了,如: <xsd:element name="internationalPrice"> <xsd:complexType> <xsd:attribute name="currency" type="xsd:string"/> <xsd:attribute name="value"type="xsd:decimal"/> </xsd:complexType> </xsd:element> 13、anyType是所有Schema类型的基类型,和Java中的Object类似。因此,以下定义: <xsd:element name="anything" type="xsd:anyType"/> 可以写成: <xsd:element name="anything"/> 14、Schema中用annotation、document、appInfo三个元素来进行注释,其中appI和document都是作为annotation的子元素来处理的。并且annotation一般是作为schema的顶层子元素、element的构造、类型定义的顶层子元素的。 如: <xsd:element name="internationalPrice"> <xsd:annotation> <xsd:documentation xml:lang="en"> element declared with anonymous type </xsd:documentation> </xsd:annotation> <xsd:complexType> <xsd:annotation> <xsd:documentation xml:lang="en"> empty anonymous type with 2 attributes </xsd:documentation> </xsd:annotation> <xsd:complexContent> <xsd:restriction base="xsd:anyType"> <xsd:attribute name="currency" type="xsd:string"/> <xsd:attribute name="value"type="xsd:decimal"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType> |