排解 XSL 轉換政策部署錯誤

您正在查看 ApigeeApigee Hybrid 說明文件。
查看 Apigee Edge 說明文件。

XSLEmptyResourceUrl

錯誤訊息

透過 Apigee UI 或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:

Error Saving Revision revision_number
Error occurred while validation of bean policy_name.xml. Reason:- Non null
value expected for element ResourceURL in XSL

錯誤訊息示例

在以下錯誤訊息範例中,導致錯誤的 XSL 轉換政策名稱為 xslt

Error Saving Revision 1
Error occurred while validation of bean xslt.xml. Reason: - Non null value
expected for element ResourceURL in XSL

螢幕截圖範例

在 Apigee UI 中,您會看到類似以下的錯誤訊息:

XSL 中的 ResourceURL 元素應為非空值。

原因

如果 XSL 轉換政策中的 <ResourceURL> 元素為空白,API Proxy 的部署作業就會失敗。

診斷

請檢查錯誤訊息中所述 XSL 轉換政策中的 <ResourceURL> 元素。如果 <ResourceURL> 元素中未指定資源網址,則是錯誤的原因。例如,下列 XSL 轉換政策包含空白的 <ResourceURL> 元素:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XSL async="false" continueOnError="false" enabled="true" name="xslt">
    <DisplayName>xslt</DisplayName>
    <Properties/>
    <ResourceURL></ResourceURL>
    <Parameters ignoreUnresolvedVariables="true"/>
    <OutputVariable/>
</XSL>

由於 <ResourceURL> 元素為空白,因此 API Proxy 的部署作業會失敗。

解決方法

請確認 XSL 轉換政策中的 <ResourceURL> 元素含有指向 XSLT 檔案的有效網址。

例如:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XSL async="false" continueOnError="false" enabled="true" name="xslt">
    <DisplayName>xslt</DisplayName>
    <Properties/>
    <ResourceURL>xsl://my_transform.xsl</ResourceURL>
    <Parameters ignoreUnresolvedVariables="true"/>
    <OutputVariable/>
</XSL>

XSLInvalidResourceType

錯誤訊息

透過 Apigee UI 或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:

Error Deploying Revision revision_number to env_name
XSL policy_name: Resource type must be xsl. Context Revision:revision_number;
APIProxy:api_proxy_name;Organization:org_name;Environment:env_name.

錯誤訊息示例

在以下錯誤訊息範例中,導致錯誤的 XSL 轉換政策名稱為 xslt

Error Deploying Revision 1 to test
XSL xslt: Resource type must be xsl. Context Revision:1;APIProxy:XSLTransform;
Organization:jdoe-test;Environment:test.

螢幕截圖範例

在 Apigee UI 中,您會看到類似以下的錯誤訊息:

資源類型必須是 xsl。

原因

如果 XSL 轉換政策的 <ResourceURL> 元素中指定的資源類型不是 xsl 類型,則 API Proxy 的部署作業會失敗。

指定此值的正確格式如下所示:

<ResourceURL>xsl://<file_name>.xsl</ResourceURL>

舉例來說,如果在 XSL 轉換政策的 <ResourceURL> 元素中,資源類型指定為 jsc,如以下所示,則 API Proxy 的部署作業會失敗:

<ResourceURL>jsc://my_transform.xsl</ResourceURL>

診斷

  1. 找出發生錯誤的 XSL 轉換政策名稱。您可以在錯誤訊息中找到這項資訊。例如,在以下錯誤中,政策名稱為 xslt

    XSL xslt: Resource type must be xsl. Context Revision:1;APIProxy:XSLTransform;
    Organization:jdoe-test;Environment:test.
    
  2. 在失敗的 XSL 轉換政策 XML 中,請確認 <ResourceURL> 元素中指定的資源類型是否為 xsl 類型。如果不是 xsl 類型,則是錯誤的原因。

    舉例來說,下列政策會在 <ResourceURL> 元素中指定非 xsl 類型:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <XSL async="false" continueOnError="false" enabled="true" name="xslt">
        <DisplayName>xslt</DisplayName>
        <Properties/>
        <ResourceURL>jsc://my_transform.xsl</ResourceURL>
        <Parameters ignoreUnresolvedVariables="true"/>
        <OutputVariable/>
    </XSL>
    

    由於資源網址指定為 jsc://my_transform.xsl,而非 xsl 類型,因此 API Proxy 的部署作業會失敗,並顯示以下錯誤訊息:

    XSL xslt: Resource type must be xsl. Context Revision:1;APIProxy:XSLTransform;
    Organization:jdoe-test;Environment:test.
    

解決方法

請確認 XSL 轉換政策的 <ResourceURL> 元素中指定的資源類型一律為 xsl 類型。例如:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XSL async="false" continueOnError="false" enabled="true" name="xslt">
    <DisplayName>xslt</DisplayName>
    <Properties/>
    <ResourceURL>xsl://my_transform.xsl</ResourceURL>
    <Parameters ignoreUnresolvedVariables="true"/>
    <OutputVariable/>
</XSL>