xmlxsltxsdoffice-jsoffice-addins

Excel Office Add-Ins manifest.xml doesn't like namespace prefixes


When building Excel Office Web Add-Ins, a manifest.xml file is required to describe the service.

Here is a simple one that opens a Taskpanel in Excel:

<?xml version="1.0" encoding="utf-8"?>
<OfficeApp
    xsi:type="TaskPaneApp"
    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:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides"
    >
    <Id>61b854ed-e679-4ae7-9c91-c04e9846f706</Id>
    <Version>0.0.0.1</Version>
    <ProviderName>MyProvider</ProviderName>
    <DefaultLocale>en-US</DefaultLocale>
    <DisplayName DefaultValue="MyDisplayName" />
    <Description DefaultValue="My Description." />
    <IconUrl DefaultValue="~remoteAppUrl/Images/Button32x32.png" />
    <SupportUrl DefaultValue="http://www.google.com" />
    <Hosts>
        <Host Name="Workbook" />
    </Hosts>
    <DefaultSettings>
        <SourceLocation DefaultValue="~remoteAppUrl/excel/" />
    </DefaultSettings>
    <Permissions>ReadWriteDocument</Permissions>
</OfficeApp>

Here is the same manifest.xml modified to use a namespace prefix. It doesn't work. Excel just ignores it and offers no error messages.

<?xml version="1.0" encoding="utf-8"?>
<x:OfficeApp
    xsi:type="x:TaskPaneApp"
    xmlns:x="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:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides"
    >
    <x:Id>61b854ed-e679-4ae7-9c91-c04e9846f706</x:Id>
    <x:Version>0.0.0.1</x:Version>
    <x:ProviderName>MyProvider</x:ProviderName>
    <x:DefaultLocale>en-US</x:DefaultLocale>
    <x:DisplayName DefaultValue="MyDisplayName" />
    <x:Description DefaultValue="My Description." />
    <x:IconUrl DefaultValue="~remoteAppUrl/Images/Button32x32.png" />
    <x:SupportUrl DefaultValue="http://www.google.com" />
    <x:Hosts>
        <x:Host Name="Workbook" />
    </x:Hosts>
    <x:DefaultSettings>
        <x:SourceLocation DefaultValue="~remoteAppUrl/excel/" />
    </x:DefaultSettings>
    <x:Permissions>ReadWriteDocument</x:Permissions>
</x:OfficeApp>

To an application, the two should be identical. And, both formats validate cleanly against the Office manifest XML Schemas.

  1. Am I correct? Excel should be able to handle namespace prefixes and I've made a mistake in translation.
  2. Am I incorrect? Excel only works with undecorated XML elements and prefixes are not allowed.

(The eventual goal is to generate the manifest from XSLT, but I'm finding it difficult without namespace prefixes.)

Thanks.

Update

The trouble with generating the right manifest XML is that when used properly, an Office manifest has two (possibly more) sections using different namespaces as the default. I don't know how to transition in XSLT without using prefixes. (perhaps this should be a different question?)

Here's an example, the elements <OfficeApp and <VersionOverrides> are in two different namespaces:

<?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:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides"
    xsi:type="TaskPaneApp"
>
    ...
    <Hosts>
        <Host Name="Workbook" />
    </Hosts>
    ...
    <VersionOverrides
        xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides"
        xsi:type="VersionOverridesV1_0"
        >
        <Hosts>
            <Host xsi:type="Workbook">
            </Host>
        </Hosts>
        ...
    </VersionOverrides>
</OfficeApp>

Solution

  • I think you are correct that Excel really should understand these XML documents identically, irrespective of what namespace prefixes (if any) are used, so long as the names of the elements are associated with the correct namespace URIs. Whether you associate a given namespace URI with an element by using a namespace prefix or without a namespace prefix (i.e. by declaring the namespace URI as the "default" namespace) really should make no difference, as it's purely a syntactical difference.

    But it is of course a detectable difference in syntax, and it doesn't surprise me hugely to learn that Excel doesn't treat these two syntactical variants equivalently, and instead requires that the http://schemas.microsoft.com/office/appforoffice/1.1 namespace URI is the default namespace, i.e. associated with the null namespace prefix.

    My advice would be to take a moment to shake your fist angrily in Microsoft's direction, but then to work around the problem by generating your elements in the default namespace, without a prefix.

    It's generally a simple thing to generate elements in a default namespace in XSLT; usually you just declare that default namespace on the root element of your stylesheet, i.e. xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" and then in your templates you create literal elements using no prefix, either like:

    <ProviderName>MyProvider</ProviderName>
    

    ... or, if you're using xsl:element, like so:

    <xsl:element name="ProviderName">MyProvider</xsl:element>
    

    If you're having some specific problem with using the default namespace, you should update your question to include sample XSLT, so we can make a more tailored suggestion.