Office加载项验证报错:Action元素含无效子元素SourceLocation
Office加载项XML验证错误解决方案
问题原因
你遇到的XML Schema验证错误,本质是**ExecuteFunction类型的<Action>元素下不能包含<SourceLocation>子元素**。根据Office加载项的XML规范,不同类型的Action有不同的必填/允许子元素:
ExecuteFunction:仅需<FunctionName>指定要执行的函数,函数逻辑定义在Commands.Url指向的脚本文件中ShowTaskpane等其他类型:才需要<SourceLocation>指定页面URL
修正后的代码片段
将原代码中<Action>内的<SourceLocation>节点删除即可:
<Control xsi:type="Button" id="AboutButton.Label"> <Label resid="AboutButton.Label"/> <Supertip> <Title resid="AboutButton.Label"/> <Description resid="AboutButton.Tooltip"/> </Supertip> <Icon> <bt:Image size="16" resid="Icon.16x16"/> <bt:Image size="32" resid="Icon.about.32x32"/> <bt:Image size="80" resid="Icon.80x80"/> </Icon> <Action xsi:type="ExecuteFunction"> <FunctionName>redirectAbout</FunctionName> </Action> <Enabled>true</Enabled> </Control>
额外说明
如果你的需求是点击按钮打开任务窗页而非执行函数,需要将Action的xsi:type改为ShowTaskpane,并保留<SourceLocation>,示例如下:
<Action xsi:type="ShowTaskpane"> <SourceLocation resid="Commands.Url"/> <TaskpaneId>MyTaskPane</TaskpaneId> </Action>
内容的提问来源于stack exchange,提问作者Thvelos
相关产品推荐
相关产品推荐

