XSD元素是否可以有多个<;注释>;?
我在XSD中有一个公共数据模式,由两个不同的应用程序a和B使用,每个应用程序使用不同的数据。我想记录每个应用程序的不同业务规则。我能做这个吗XSD元素是否可以有多个<;注释>;?,xsd,annotations,Xsd,Annotations,我在XSD中有一个公共数据模式,由两个不同的应用程序a和B使用,每个应用程序使用不同的数据。我想记录每个应用程序的不同业务规则。我能做这个吗 <xs:complexType name="Account"> <xs:annotation app="A"> <xs:documentation> The Account entity must be used this way for app A </xs:docu
<xs:complexType name="Account">
<xs:annotation app="A">
<xs:documentation>
The Account entity must be used this way for app A
</xs:documentation>
</xs:annotation>
<xs:annotation app="B">
<xs:documentation>
The Account entity must be used this way for app B
</xs:documentation>
</xs:annotation>
<xs:complexContent>
...
应用程序A必须以这种方式使用帐户实体
应用程序B必须以这种方式使用帐户实体
...
在注释
元素中使用,并指定应用程序要使用的信息:
<xs:annotation>
<xs:appinfo>Any well-formed XML content here</xs:appinfo>
</xs:annotation>
这里有格式良好的XML内容吗
因为任何XML内容都是有效的,所以您可以创建自己的特定于应用程序的元数据,并将其放入
appinfo
元素中。显然不是,因为XML模式规范规定,在使用注释时,必须显示元素内容的注释。但是,注释
元素可以有您想要的任意多个(或appinfo
)元素。可以使用属性来区分这些元素。在文档
元素中还可以有多个子元素(任何类型)
因此,编写模式的一种方法可能如下所示:
<xs:complexType name="Account">
<xs:annotation >
<xs:documentation app="A">
The Account entity must be used this way for app A
</xs:documentation>
<xs:documentation app="B">
The Account entity must be used this way for app B
</xs:documentation>
</xs:annotation>
<xs:complexContent>
...
应用程序A必须以这种方式使用帐户实体
应用程序B必须以这种方式使用帐户实体
...