<srcschema>
的基本結構如下:
<srcSchema>
<enumeration>
... //definition of enumerations
</enumeration>
<element> //definition of the root <element> (mandatory)
<compute-string/> //definition of a compute-string
<dbindex>
... //definition of indexes
</dbindex>
<key>
... //definition of keys
</key>
<sysFilter>
... //definition of filters
</sysFilter>
<attribute>
... //definition of fields
</attribute>
<element> //definition of sub-<element>
<attribute> //(collection, links or XML)
... //and additional fields
</attribute>
...
</element>
</element>
<methods> //definition of SOAP methods
<method>
...
</method>
...
</methods>
</srcSchema>
資料架構的XML文檔必須包含<srcschema>
根元素,其中name和namespace屬性必須填入架構名稱及其命名空間。
<srcSchema name="schema_name" namespace="namespace">
...
</srcSchema>
讓我們使用下列XML內容來說明資料架構的結構:
<recipient email="John.doe@aol.com" created="2009/03/12" gender="1">
<location city="London"/>
</recipient>
使用其對應的資料模式:
<srcSchema name="recipient" namespace="cus">
<element name="recipient">
<attribute name="email"/>
<attribute name="created"/>
<attribute name="gender"/>
<element name="location">
<attribute name="city"/>
</element>
</element>
</srcSchema>
方案的入口點是其主要元素。 很容易識別,因為它與結構相同,而且應是根元素的子項。 內容的說明以此元素開始。
在我們的示例中,主要元素由以下行表示:
<element name="recipient">
主要元素後面的<attribute>
和<element>
元素可讓您定義XML結構中資料項的位置和名稱。
在我們的範例架構中,以下是:
<attribute name="email"/>
<attribute name="created"/>
<attribute name="gender"/>
<element name="location">
<attribute name="city"/>
</element>
必須遵守下列規定:
每個<element>
和<attribute>
必須通過name屬性以名稱標識。
元素的名稱應簡明扼要,最好是英文,並且只包含符合XML命名規則的授權字元。
在XML結構中,只有<element>
元素可以包含<attribute>
元素和<element>
元素。
<attribute>
元素在<element>
中必須有唯一的名稱。
建議在多行資料字串中使用<elements>
。
資料類型是通過<attribute>
和<element>
元素中的type屬性輸入的。
<attribute>
元素和<element>
元素的說明中提供了詳細清單。
如果未填入此屬性,除非元素包含子元素,否則string是預設資料類型。 如果是,則僅用於分層結構元素(在本例中為<location>
元素)。
架構支援下列資料類型:
字串:字元字串。範例:名字,鎮子,等等。
可以通過length屬性指定大小(可選,預設值"255")。
布林值:布林欄位。可能值的範例:true/false、0/1、yes/no等。
byte, short, long:整數(1位元組、2位元組、4位元組)。範例:年齡、帳號、點數等。
雙重:雙精度浮點數。範例:價格、費率等。
date, datetime:日期和日期+時間。範例:出生日期、購買日期等。
datetimenotz:日期+時間,不含時區資料。
時間平移:持續時間。範例:資歷。
備忘:長文字欄位(多行)。範例:說明、注釋等。
uuid:「uniqueidentifier」欄位,以支援GUID(僅限Microsoft SQL Server支援)。
要在Microsoft SQL Server以外的引擎中包含uuid欄位,必須添加"newuuid()"函式並使用其預設值完成。
以下是我們輸入類型的範例架構:
<srcSchema name="recipient" namespace="cus">
<element name="recipient">
<attribute name="email" type="string" length="80"/>
<attribute name="created" type="datetime"/>
<attribute name="gender" type="byte"/>
<element name="location">
<attribute name="city" type="string" length="50"/>
</element>
</element>
</srcSchema>
下表列出Adobe Campaign為不同資料庫管理系統產生的資料類型對應。
Adobe Campaign |
PosgreSQL |
Oracle |
Teradata |
DB2 |
MS SQL |
String |
VARCHAR(255) |
VARCHAR2(NVARCHAR2 if unicode) |
VARCHAR(如果是Unicode,則為VARCHAR字元集UNICODE) |
VARCHAR |
VARCHAR(NVARCHAR if unicode) |
布爾 |
SMALLINT |
NUMBER(3) |
NUMERIC(3) |
SMALLINT |
TINYINT |
位元組 |
SMALLINT |
NUMBER(3) |
NUMERIC(3) |
SMALLINT |
TINYINT |
短 |
SMALLINT |
NUMBER(5) |
SMALLINT |
SMALLINT |
SMALLINT |
Double |
雙精度 |
FLOAT |
FLOAT |
DOUBLE |
FLOAT |
長 |
INTEGER |
NUMBER(10) |
INTEGER |
INTEGER |
INT |
Int64 |
BIGINT |
NUMBER(20) |
NUMERIC(20) |
BIGINT |
BIGINT |
日期 |
DATE |
DATE |
TIMESTAMP |
DATE |
DATETIME |
時間 |
TIME |
FLOAT |
TIME |
TIME |
FLOAT |
日期時間 |
時間戳記 |
DATE |
TIMESTAMP |
TIMESTAMP |
MS SQL < 2008:DATETIME MS SQL >= 2012:DATETIMEOFFSET |
Datetimenotz |
時間戳記 |
DATE |
TIMESTAMP |
TIMESTAMP |
MS SQL < 2008:DATETIME MS SQL >= 2012:DATETIME2 |
時間平移 |
雙精度 |
FLOAT |
FLOAT |
DOUBLE |
FLOAT |
備忘錄 |
TEXT |
CLOB(如果為Unicode,則為NCLOB) |
CLOB(如果為Unicode,則為CLOB字元集UNICODE) |
CLOB(6M) |
TEXT(NTEXT if Unicode) |
Blob |
BLOB |
BLOB |
BLOB |
BLOB(4M) |
IMAGE |
資料架構的<elements>
和<attributes>
元素可以用各種屬性進行豐富。 您可以填入標籤,以說明目前的元素。
label屬性可讓您輸入簡短說明。
標籤與實例的當前語言相關聯。
範例:
<attribute name="email" type="string" length="80" label="Email"/>
您可從Adobe Campaign用戶端主控台輸入表單中查看標籤:
desc屬性可讓您輸入詳細說明。
說明可從Adobe Campaign用戶端主控台主視窗的狀態列的輸入表單中檢視。
說明與實例的當前語言相關聯。
範例:
<attribute name="email" type="string" length="80" label="Email" desc="Email of recipient"/>
default屬性可讓您定義在內容建立時傳回預設值的運算式。
值必須是與XPath語言相容的運算式。 有關詳細資訊,請參閱Referencing with XPath。
範例:
目前日期:default="GetDate()"
計數器:default="'FRM'+CounterValue('myCounter')"
在此示例中,預設值是使用字串的串連來構造的,並使用自由計數器名稱調用CounterValue函式。 每次插入時傳回的數字會增加一。
在Adobe Campaign用戶端主控台中,Administration>Counters節點用於管理計數器。
若要將預設值連結至欄位,您可使用<default> or <sqldefault> field. </sqldefault> </default>
<default>
:允許您在建立圖元時用預設值預填充欄位。該值將不是預設的SQL值。
<sqldefault>
:可讓您在建立欄位時增加值。此值以SQL結果顯示。 在模式更新期間,只有新記錄會受到此值的影響。
userEnum屬性可讓您定義免費列舉,以記憶和顯示透過此欄位輸入的值。 語法如下:
userEnum="枚舉的名稱"
可自由選擇列舉的名稱,並與其他欄位共用。
這些值顯示在輸入表單的下拉式清單中:
在Adobe Campaign用戶端主控台中,Administration > Enumerations節點用於管理枚舉。
enum屬性可讓您定義在事先已知可能值清單時所使用的固定列舉。
enum屬性參照在主元素之外的模式中填充的枚舉類的定義。
枚舉允許用戶從下拉清單中選擇一個值,而不是在常規輸入欄位中輸入值:
資料模式中枚舉聲明的示例:
<enumeration name="gender" basetype="byte" default="0">
<value name="unknown" label="Not specified" value="0"/>
<value name="male" label="male" value="1"/>
<value name="female" label="female" value="2"/>
</enumeration>
會透過<enumeration>
元素在主要元素外部宣告列舉。
枚舉屬性如下:
枚舉值在<value>
元素中聲明,具有以下屬性:
dbenum屬性可讓您定義屬性與enum屬性相似的列舉。
但是,name屬性不會在內部儲存值,它會儲存程式碼,讓您在不修改其架構的情況下擴充相關表。
這些值是通過Administration>Enumerations節點定義的。
例如,此列舉用於指定促銷活動的性質。
以下是我們的範例架構,其中填入了屬性:
<srcSchema name="recipient" namespace="cus">
<enumeration name="gender" basetype="byte">
<value name="unknown" label="Not specified" value="0"/>
<value name="male" label="male" value="1"/>
<value name="female" label="female" value="2"/>
</enumeration>
<element name="recipient">
<attribute name="email" type="string" length="80" label="Email" desc="Email of recipient"/>
<attribute name="created" type="datetime" label="Date of creation" default="GetDate()"/>
<attribute name="gender" type="byte" label="gender" enum="gender"/>
<element name="location" label="Location">
<attribute name="city" type="string" length="50" label="City" userEnum="city"/>
</element>
</element>
</srcSchema>
系列是具有相同名稱和相同階層層級的元素清單。
unbound屬性的值"true"可讓您填入系列元素。
範例:架構中 <group>
的集合元素定義。
<element name="group" unbound="true" label="List of groups">
<attribute name="label" type="string" label="Label"/>
</element>
運用XML內容的投影:
<group label="Group1"/>
<group label="Group2"/>
Adobe Campaign使用XPath語言來參考屬於資料結構的元素或屬性。
XPath是一種語法,可讓您在XML文檔的樹狀結構中找到節點。
元素由其名稱指定,屬性由名稱前面帶有字元"@"指定。
範例:
<location>
性[1]/@label
:選擇作為第一個收集元素子項的「標籤」 <group>
屬性[@label='test1']
:選擇元素的子項"label"屬性, <group>
並包含值"test1"當路徑與子元素交叉時,將添加附加約束。 在這種情況下,下列運算式必須置於方括弧之間:
[location/@city]
[@email]
和 @ emailare等同您也可以定義複雜的運算式,例如下列算術運算:
為了豐富該語言的潛力,在表達式中增加了高級函式。
您可以透過Adobe Campaign用戶端主控台中的任何運算式編輯器,存取可用函式清單:
範例:
計算字串是XPath表達式,用於構建表示與模式相關聯的表中的記錄的字串。 計 算字串主要用於圖形介面,以顯示選定記錄的標籤。
計算字串是通過資料架構主要元素下的<compute-string>
元素定義的。 expr屬性包含用於計算顯示的XPath表達式。
範例:收件者表格的計算字串。
<srcSchema name="recipient" namespace="nms">
<element name="recipient">
<compute-string expr="@lastName + ' ' + @firstName +' (' + @email + ')' "/>
...
</element>
</srcSchema>
收件者的計算字串結果:Doe John(john.doe@aol.com)
如果方案不包含計算字串,則預設情況下,計算字串將填充方案的主鍵值。