2010-12-30 4 views
1

2つの異なるアプリケーションAとBで使用されるXSDに共通のデータスキーマがあり、それぞれ異なるデータが使用されています。私はアプリケーションごとに異なるビジネスルールを文書化したいと思います。これはできますか?XSD要素に複数の<annotation>がありますか?

<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> 
    ... 

答えて

1

appinfo elementannotation要素内で使用され、アプリケーションが使用する情報を指定します

<xs:annotation> 
    <xs:appinfo>Any well-formed XML content here</xs:appinfo> 
</xs:annotation> 

任意のXMLコンテンツが有効であるので、あなたがあなた自身のアプリケーション固有のメタデータを作成して置くことができますそれはappinfo要素です。

1

XMLスキーマの仕様では、注釈を使用するときに要素のコンテンツのat the beginningが表示されている必要があります。ただし、annotation要素には、希望するとおりに多くの要素を含めることができます(documentationまたはappinfo)。これらの要素は属性を使用して区別できます。また、documentation要素内に複数の子(任意の型の)を持つことができます。

だから、あなたのスキーマを書き込むことの一つの方法は、次のようになります。

<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> 
... 
関連する問題