在 Office 加载项清单中,为什么 <Permissions> 必须紧跟在 <FormSettings/> 之后?
In an Office add-in manifest, why must <Permissions> immediately follow <FormSettings/>?
这个问题最好用例子来说明。考虑以下因素:
在第一个示例中,我的 <Permissions/>
元素紧跟在 <FormSettings/>
块之后:
<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp">
<Id>464672b2-35a8-44a1-8c06-3ad07ed893a7</Id>
<Version>1.0.0.0</Version>
<ProviderName>Example</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Example A"/>
<Description DefaultValue="This is an example add-in."/>
<IconUrl DefaultValue="https://placehold.it/64x64"/>
<HighResolutionIconUrl DefaultValue="https://placehold.it/64x64"/>
<SupportUrl DefaultValue="https://example.com/"/>
<Hosts>
<Host Name="Mailbox"/>
</Hosts>
<Requirements>
<Sets>
<Set Name="MailBox" MinVersion="1.1"/>
</Sets>
</Requirements>
<FormSettings>
<Form xsi:type="ItemEdit">
<DesktopSettings>
<SourceLocation DefaultValue="https://example.com"/>
</DesktopSettings>
</Form>
</FormSettings>
<Permissions>ReadWriteMailbox</Permissions>
<Rule xsi:type="RuleCollection" Mode="And">
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Edit"/>
</Rule>
</OfficeApp>
我能够成功将此清单添加到我的 Exchange 管理中心的组织加载项列表中。
但是,如果我将 <Permissions/>
元素移动到清单中的其他任何地方 ,清单在尝试添加它时验证失败:
<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp">
<Id>464672b2-35a8-44a1-8c06-3ad07ed893a7</Id>
<Version>1.0.0.0</Version>
<ProviderName>Example</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Example A"/>
<Description DefaultValue="This is an example add-in."/>
<IconUrl DefaultValue="https://placehold.it/64x64"/>
<HighResolutionIconUrl DefaultValue="https://placehold.it/64x64"/>
<SupportUrl DefaultValue="https://example.com/"/>
<Hosts>
<Host Name="Mailbox"/>
</Hosts>
<Requirements>
<Sets>
<Set Name="MailBox" MinVersion="1.1"/>
</Sets>
</Requirements>
<FormSettings>
<Form xsi:type="ItemEdit">
<DesktopSettings>
<SourceLocation DefaultValue="https://example.com"/>
</DesktopSettings>
</Form>
</FormSettings>
<Rule xsi:type="RuleCollection" Mode="And">
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Edit"/>
</Rule>
<Permissions>ReadWriteMailbox</Permissions>
</OfficeApp>
尝试将此清单添加到我的 Exchange 管理中心的组织加载项列表中会产生以下错误:
This app can't be installed. The manifest file doesn't conform to the schema definition. The element 'OfficeApp' in namespace 'http://schemas.microsoft.com/office/appforoffice/1.1' has invalid child element 'Permissions' in namespace 'http://schemas.microsoft.com/office/appforoffice/1.1'. List of possible elements expected: 'DisableEntityHighlighting' in namespace 'http://schemas.microsoft.com/office/appforoffice/1.1' as well as 'VersionOverrides' in namespace 'http://schemas.microsoft.com/office/mailappversionoverrides' as well as any element in namespace 'http://www.w3.org/2000/09/xmldsig#'...
只有通过反复试验,我们才能找到验证失败的根本原因。
我的问题:为什么顺序很重要?为什么 <Permissions/>
元素不能出现在清单中同一嵌套级别的任何位置?
上下文
此验证失败发生在托管 Exchange (Office 365) 中,并且在尝试将加载项提交到 Office Store 时,在请求清单的步骤中。
Why does ordering matter?
架构文件定义的标签顺序。在您的情况下,您已包含在清单 http://schemas.microsoft.com/office/appforoffice/1.1 架构中。尝试在架构 <Permissions/>
元素中查找,您将看到以下定义 ...
<xs:complexType name="MailApp">
<xs:complexContent>
<xs:extension base="OfficeApp">
<xs:sequence>
<xs:element name="Requirements" type="MailAppRequirements" minOccurs="1" maxOccurs="1"/>
<xs:element name="FormSettings" type="FormSettings" minOccurs="1" maxOccurs="1"/>
<xs:element name="Permissions" minOccurs="0" maxOccurs="1" type="ST_Permissions2"/>
<xs:element name="Rule" type="Rule" minOccurs="1" maxOccurs="1"/>
<xs:element name="DisableEntityHighlighting" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
<xs:element ref="mailor:VersionOverrides" minOccurs="0" maxOccurs="1"/>
<xs:any id="MailAppSignature" minOccurs="0" maxOccurs="1" namespace="http://www.w3.org/2000/09/xmldsig#" processContents="lax"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
元素 <Permissions/>
在 <sequence/>
中,这意味着它必须按此元素定义的顺序排列,并且它紧跟在 <FormSettings/>
之后,其他任何地方都没有。
架构文件定义的标签顺序。不幸的是,这没有很好的记录,我们正在努力改进这个文档。由于我们验证安装架构的方式,在为 Outlook Web 加载项定义清单时,顺序很重要。我们意识到这可能会很麻烦 尤其是 因为它没有很好的记录,但我们需要特定顺序的主要原因是因为它允许我们快速验证清单内容并提高服务的性能。
感谢您对我们的文档提供反馈。
Outlook Web 插件团队
这个问题最好用例子来说明。考虑以下因素:
在第一个示例中,我的 <Permissions/>
元素紧跟在 <FormSettings/>
块之后:
<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp">
<Id>464672b2-35a8-44a1-8c06-3ad07ed893a7</Id>
<Version>1.0.0.0</Version>
<ProviderName>Example</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Example A"/>
<Description DefaultValue="This is an example add-in."/>
<IconUrl DefaultValue="https://placehold.it/64x64"/>
<HighResolutionIconUrl DefaultValue="https://placehold.it/64x64"/>
<SupportUrl DefaultValue="https://example.com/"/>
<Hosts>
<Host Name="Mailbox"/>
</Hosts>
<Requirements>
<Sets>
<Set Name="MailBox" MinVersion="1.1"/>
</Sets>
</Requirements>
<FormSettings>
<Form xsi:type="ItemEdit">
<DesktopSettings>
<SourceLocation DefaultValue="https://example.com"/>
</DesktopSettings>
</Form>
</FormSettings>
<Permissions>ReadWriteMailbox</Permissions>
<Rule xsi:type="RuleCollection" Mode="And">
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Edit"/>
</Rule>
</OfficeApp>
我能够成功将此清单添加到我的 Exchange 管理中心的组织加载项列表中。
但是,如果我将 <Permissions/>
元素移动到清单中的其他任何地方 ,清单在尝试添加它时验证失败:
<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp">
<Id>464672b2-35a8-44a1-8c06-3ad07ed893a7</Id>
<Version>1.0.0.0</Version>
<ProviderName>Example</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Example A"/>
<Description DefaultValue="This is an example add-in."/>
<IconUrl DefaultValue="https://placehold.it/64x64"/>
<HighResolutionIconUrl DefaultValue="https://placehold.it/64x64"/>
<SupportUrl DefaultValue="https://example.com/"/>
<Hosts>
<Host Name="Mailbox"/>
</Hosts>
<Requirements>
<Sets>
<Set Name="MailBox" MinVersion="1.1"/>
</Sets>
</Requirements>
<FormSettings>
<Form xsi:type="ItemEdit">
<DesktopSettings>
<SourceLocation DefaultValue="https://example.com"/>
</DesktopSettings>
</Form>
</FormSettings>
<Rule xsi:type="RuleCollection" Mode="And">
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Edit"/>
</Rule>
<Permissions>ReadWriteMailbox</Permissions>
</OfficeApp>
尝试将此清单添加到我的 Exchange 管理中心的组织加载项列表中会产生以下错误:
This app can't be installed. The manifest file doesn't conform to the schema definition. The element 'OfficeApp' in namespace 'http://schemas.microsoft.com/office/appforoffice/1.1' has invalid child element 'Permissions' in namespace 'http://schemas.microsoft.com/office/appforoffice/1.1'. List of possible elements expected: 'DisableEntityHighlighting' in namespace 'http://schemas.microsoft.com/office/appforoffice/1.1' as well as 'VersionOverrides' in namespace 'http://schemas.microsoft.com/office/mailappversionoverrides' as well as any element in namespace 'http://www.w3.org/2000/09/xmldsig#'...
只有通过反复试验,我们才能找到验证失败的根本原因。
我的问题:为什么顺序很重要?为什么 <Permissions/>
元素不能出现在清单中同一嵌套级别的任何位置?
上下文
此验证失败发生在托管 Exchange (Office 365) 中,并且在尝试将加载项提交到 Office Store 时,在请求清单的步骤中。
Why does ordering matter?
架构文件定义的标签顺序。在您的情况下,您已包含在清单 http://schemas.microsoft.com/office/appforoffice/1.1 架构中。尝试在架构 <Permissions/>
元素中查找,您将看到以下定义 ...
<xs:complexType name="MailApp">
<xs:complexContent>
<xs:extension base="OfficeApp">
<xs:sequence>
<xs:element name="Requirements" type="MailAppRequirements" minOccurs="1" maxOccurs="1"/>
<xs:element name="FormSettings" type="FormSettings" minOccurs="1" maxOccurs="1"/>
<xs:element name="Permissions" minOccurs="0" maxOccurs="1" type="ST_Permissions2"/>
<xs:element name="Rule" type="Rule" minOccurs="1" maxOccurs="1"/>
<xs:element name="DisableEntityHighlighting" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
<xs:element ref="mailor:VersionOverrides" minOccurs="0" maxOccurs="1"/>
<xs:any id="MailAppSignature" minOccurs="0" maxOccurs="1" namespace="http://www.w3.org/2000/09/xmldsig#" processContents="lax"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
元素 <Permissions/>
在 <sequence/>
中,这意味着它必须按此元素定义的顺序排列,并且它紧跟在 <FormSettings/>
之后,其他任何地方都没有。
架构文件定义的标签顺序。不幸的是,这没有很好的记录,我们正在努力改进这个文档。由于我们验证安装架构的方式,在为 Outlook Web 加载项定义清单时,顺序很重要。我们意识到这可能会很麻烦 尤其是 因为它没有很好的记录,但我们需要特定顺序的主要原因是因为它允许我们快速验证清单内容并提高服务的性能。
感谢您对我们的文档提供反馈。
Outlook Web 插件团队