關於驗證

WebSphere Partner Gateway 使用驗證對映來驗證 RosettaNet 訊息的服務內容。這些驗證對映會定義有效訊息的結構, 以及定義訊息中之元素的基數、格式和有效值(列舉)。在每一個 PIP 文件流程資料包中, WebSphere Partner Gateway 會在 GuidelineMaps 目錄中以 XSD 檔格式來提供驗證對映。

由於 RosettaNet 會指定 PIP 訊息的格式,一般而言, 您不必自訂驗證對映。不過,如果您要如此做, 請參閱建立 PIP 文件流程資料包,取得升級所用 XSD 檔以驗證訊息時所需執行的步驟資訊, 以及瞭解如何建立自訂 PIP 文件流程資料包。

基數

基數用以決定特定元素在訊息中所能(或必須)出現的次數。在驗證對映中, minOccurs 和 maxOccurs 屬性用以決定屬性的基數;請見下列範例(取自 BCG_5C4RegistrationStatusNotification_V01.02.xsd):

<xsd:element name="GeographicRegion" type="GeographicRegionType"
     minOccurs="0"/> 

如果 WebSphere Partner Gateway 不需檢查元素的基數,則在驗證對映中, 元素的 minOccurs 和 maxOccurs 屬性值會是 "0" 和 "unbounded";請見下列範例:

<xsd:element name="DesignRegistrationIdentification" 
     type="DesignRegistrationIdentificationType2"
     minOccurs="0" maxOccurs="unbounded"/> 

格式

格式是決定元素類型的資料安排或佈置。在驗證對映中, 類型會有一或多項限制;請見下列範例:

範例 1

<xsd:simpleType name="_common_LineNumber_R">
   <xsd:restriction base="xsd:string">
     <xsd:minLength value="1" /> 
     <xsd:maxLength value="6" /> 
     </xsd:restriction>
   </xsd:simpleType>

訊息中的所有 _common_LineNumber_R 類型元素皆必須是「字串」,且長度必須是 1 到 6 個字元。

範例 2

<xsd:simpleType name="_GlobalLocationIdentifier">
   <xsd:restriction base="xsd:string">
     <xsd:pattern value="[0-9]{9}.{1,4}" /> 
     </xsd:restriction>
   </xsd:simpleType>

訊息中的所有 _GlobalLocationIdentifier 類型元素皆必須是「字串」, 且必須是 9 個字元的數值資料, 後面跟著 1 到 4 個字元的英數資料。因此長度最少是 10 個字元,最多 13 個字元。

範例 3

<xsd:element name="DayOfMonth">
   <xsd:simpleType>
     <xsd:restriction base="xsd:positiveInteger">
       <xsd:totalDigits value="2" /> 
       <xsd:minInclusive value="1" /> 
       <xsd:maxInclusive value="31" /> 
     </xsd:restriction>
   </xsd:simpleType>
 </xsd:element>

訊息中所有的 _DayofMonth 類型元素皆必須是 1 到 2 個字元的「正整數」, 其值可為 1 到 31。

列舉

列舉是決定元素的有效值。在驗證對映中, 元素的類型會有一或多項列舉限制;請見下列範例:

<xsd:simpleType name="_local_GlobalDesignRegistrationNotificationCode">
   <xsd:restriction base="xsd:string">
     <xsd:enumeration value="Initial" /> 
     <xsd:enumeration value="Update" /> 
     </xsd:restriction>
   </xsd:simpleType>

訊息中所有 _local_GlobalDesignRegistrationNotificationCode 類型元素的值只能是 "Initial" 或 "Update"。

Copyright IBM Corp. 2003, 2005