Experience Data Model (XDM)中的名稱空間

IMPORTANT
在XDM中,名稱空間(此頁面主題)是用來區分結構描述中的欄位。 這與Identity Service中的身分名稱空間概念不同,該概念會使用名稱空間來區分身分值。 請閱讀以下檔案: 身分服務中的名稱空間 以取得詳細資訊。

體驗資料模型(XDM)結構描述中的所有欄位都有關聯的名稱空間。 這些名稱空間可讓您擴充結構描述,並在不同結構描述元件彙整時防止欄位衝突。 本檔案概述XDM中的名稱空間,以及這些名稱空間在 結構描述登入API.

名稱空間可讓您在一個名稱空間中定義欄位,以表示不同名稱空間中相同欄位的意義。 實際上,欄位的名稱空間會指出建立欄位的人員(例如標準XDM (Adobe)、廠商或您的組織)。

例如,假設某個XDM結構描述使用 個人聯絡詳細資訊 欄位群組,此版本有標準 mobilePhone 存在於中的欄位 xdm 名稱空間。 在同一個結構描述中,您也可以自由建立個別的 mobilePhone 不同名稱空間下的欄位(您的 租使用者ID)。 這兩個欄位可以共存,但具有不同的基本含義或限制。

名稱空間語法

以下章節示範如何以XDM語法指派名稱空間。

標準XDM standard

標準XDM語法可讓您深入瞭解名稱空間在結構描述中的呈現方式(包括 如何在Adobe Experience Platform中翻譯它們)。

標準XDM使用 JSON-LD 指派名稱空間給欄位的語法。 此名稱空間採用URI的形式(例如 https://ns.adobe.com/xdm 針對 xdm 名稱空間),或設為 @context 結構描述的屬性。

以下是標準XDM語法中產品的結構描述範例。 例外情況: @id (由JSON-LD規格定義的唯一識別碼),下方每個欄位 properties 以名稱空間開頭並以欄位名稱結尾。 如果使用下定義的速記首碼 @context,名稱空間和欄位名稱會以冒號(:)。 如果不使用首碼,則名稱空間和欄位名稱會以斜線(/)。

{
  "$id": "https://ns.adobe.com/xdm/schemas/mySchema",
  "title": "Product",
  "description": "Represents the definition of a Project",
  "@context": {
    "xdm": "https://ns.adobe.com/xdm",
    "repo": "http://ns.adobe.com/adobecloud/core/1.0/",
    "schema": "http://schema.org",
    "tenantId": "https://ns.adobe.com/tenantId"
  },
  "properties": {
    "@id": {
      "type": "string"
    },
    "xdm:sku": {
      "type": "string"
    },
    "xdm:name": {
      "type": "string"
    },
    "repo:createdDate": {
      "type": "string",
      "format": "datetime"
    },
    "https://ns.adobe.com/xdm/channels/application": {
      "type": "string"
    },
    "schema:latitude": {
      "type": "number"
    },
    "https://ns.adobe.com/vendorA/product/stockNumber": {
      "type": "string"
    },
    "tenantId:internalSku": {
      "type": "number"
    }
  }
}
屬性
說明
@context
一個物件,定義可用來取代下的完整名稱空間URI的速記首碼 properties.
@id
記錄的唯一識別碼,由 JSON-LD規格.
xdm:sku
使用速記首碼表示名稱空間的欄位範例。 在這種情況下, xdm 是名稱空間(https://ns.adobe.com/xdm),以及 sku 是欄位名稱。
https://ns.adobe.com/xdm/channels/application
使用完整名稱空間URI的欄位範例。 在這種情況下, https://ns.adobe.com/xdm/channels 是名稱空間,並且 application 是欄位名稱。
https://ns.adobe.com/vendorA/product/stockNumber
廠商資源提供的欄位會使用其專屬的名稱空間。 在此範例中, https://ns.adobe.com/vendorA/product 是廠商名稱空間,且 stockNumber 是欄位名稱。
tenantId:internalSku
貴組織定義的欄位會使用您的唯一租使用者ID作為其名稱空間。 在此範例中, tenantId 是租使用者名稱空間(https://ns.adobe.com/tenantId),以及 internalSku 是欄位名稱。

相容性模式 compatibility

在Adobe Experience Platform中,XDM結構描述會以 相容性模式 語法,不會使用JSON-LD語法來表示名稱空間。 Platform會將名稱空間轉換為父欄位(以底線開頭),並將欄位巢狀在其下。

例如,標準XDM repo:createdDate 已轉換為 _repo.createdDate 和,在「相容性模式」中會顯示在下列結構下:

"_repo": {
  "type": "object",
  "properties": {
    "createdDate": {
      "type": "string",
      "format": "datetime"
    }
  }
}

使用 xdm 名稱空間會顯示為下方的根欄位 properties 並放置 xdm: 前置詞,出現在 標準XDM語法. 例如, xdm:sku 只會列為 sku 而非。

以下JSON代表如何將以上所示的標準XDM語法範例轉譯為相容性模式。

{
  "$id": "https://ns.adobe.com/xdm/schemas/mySchema",
  "title": "Product",
  "description": "Represents the definition of a Project",
  "properties": {
    "_id": {
      "type": "string"
    },
    "sku": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "_repo": {
      "type": "object",
      "properties": {
        "createdDate": {
          "type": "string",
          "format": "datetime"
        }
      }
    },
    "_channels": {
      "type": "object",
      "properties": {
        "application": {
          "type": "string"
        }
      }
    },
    "_schema": {
      "type": "object",
      "properties": {
        "application": {
          "type": "string"
        }
      }
    },
    "_vendorA": {
      "type": "object",
      "properties": {
        "product": {
          "type": "object",
          "properties": {
            "stockNumber": {
              "type": "string"
            }
          }
        }
      }
    },
    "_tenantId": {
      "type": "object",
      "properties": {
        "internalSku": {
          "type": "number"
        }
      }
    }
  }
}

後續步驟

本指南概述XDM名稱空間及其在JSON中的呈現方式。 如需有關如何使用API設定XDM綱要的詳細資訊,請參閱 結構描述登入API指南.

recommendation-more-help
62e9ffd9-1c74-4cef-8f47-0d00af32fc07