找不到与命名空间“http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument”关联的脚本或扩展对象

时间:2013-05-17 04:47:52

标签: c# xslt infopath msxml

我尝试将InfoPath文档XSLT从XML转换为HTML,我收到以下错误:

Cannot find a script or an extension object associated with namespace 'http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument'.

甚至可以转换文件吗?我注意到XSL使用了xdXDocument:GetDOM等函数,它们看起来像旧的MSXML语法。你能在转换过程中添加对MSXML的支持吗?

作为参考,命名空间是:

xmlns:xdXDocument="http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument" 

This article建议您只使用InfoPath文档的打印视图 - 但我认为这可能是InfoPath 2007独有的(2010年后,您似乎可以打印任何视图)。


顺便说一句,我也试过使用MSXML,我也遇到了类似的错误:

Namespace 'http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument' does not contain any functions.

这是我的MSXML代码:

var xml = new MSXML2.DOMDocument60();
xml.load(txtXmlFilePath.Text);
var lines = File.ReadAllLines(txtXslFilePath.Text);

// Seemingly need to strip out first <?xml... /> line to work
string sXsl = string.Join("\n", lines.Skip(1).ToArray());

var xsl = new MSXML2.DOMDocument60();
xsl.loadXML(sXsl);

string html = xml.transformNode(xsl);

所以基本问题仍然存在 - 如何将XSLT转换为InfoPath文档?

1 个答案:

答案 0 :(得分:2)

xdXDocument:GetDOM()是一个扩展函数,用于从InfoPath中的辅助数据源访问数据。我已经处理了使用InfoPath视图XSLT将InfoPath XML文档转换为HTML的任务,我知道处理这些扩展函数的唯一方法是编写实现它们的扩展对象(您可以实现只返回空的虚拟扩展对象)这些函数的节点集,如果你不需要它们。

另一种方法是创建一个视图,该视图没有对表单的辅助数据源的任何引用。