Matlab部署归档中内置matlab.io.xml.dom.Parser类无法识别问题
Matlab Production Server编译CTF时
matlab.io.xml.dom.Parser未被识别问题 问题概述
使用mcc编译用于Matlab Production Server的可部署归档(CTF)后,部署环境调用函数时触发报错:
Unrecognized function or variable 'matlab.io.xml.dom.Parser'
函数中使用了matlab.io.xml.dom命名空间下的内置Parser类,调用方式符合官方示例:doc = parseString(Parser,xmlString);
已尝试操作
- 在代码中添加
import matlab.io.xml.dom.*或import matlab.io.xml.dom.Parser,问题未解决 - 参考过相关解决方案,但存在两个顾虑:
- 无法确定编译代理上内置类的具体路径,无法使用
mcc的-I参数指定 - 后续新增内置类时需要频繁修改构建流水线,扩展性差
- 无法确定编译代理上内置类的具体路径,无法使用
关键差异现象
将出错代码片段提取到独立CTF中单独编译测试时,未出现报错。相关文件及命令如下:
测试用Matlab代码
function doSomething(XmlFile) if isfile(XmlFile) xml = xmlread(XmlFile); else if verLessThan('matlab','9.10') %throw error else import matlab.io.xml.dom.* xml = parseString(Parser,XmlFile); end end end
函数签名文件
{ "_schemaVersion": "1.1.0", "importExample": { "inputs": [ { "name": "xmlData", "type": [], "purpose": "" } ], "outputs": [ { "name": "output", "type": [], "purpose": "" } ] } }
编译命令
mcc -U -W 'CTF:importExample,DISCOVERY:./importExampleFunctionSignatures.json' importExample.m
疑问
使用Matlab 2021b,希望明确原项目CTF编译异常与独立测试CTF正常之间的差异原因。
内容的提问来源于stack exchange,提问作者gaborhodi
相关产品推荐
相关产品推荐

