如何使用.Net Xsl处理器捕获不明确的Xslt模板匹配?

时间:2017-09-20 19:50:47

标签: c# xml xslt xslt-1.0

如原始问题所述,使用Saxon xsl处理器和链接XSLT Error produced "Ambiguous rule match"中的输入xml和xsl文件,Saxon处理器生成模糊规则匹配错误/警告。

我试图通过.Net xsl处理器生成相同或类似的消息,但我没有成功。如果有人知道这是否可能,任何建议将不胜感激。

以下是我正在使用的代码段:

        XmlUrlResolver resolver = new XmlUrlResolver();

        XslCompiledTransform xsltTrans = new XslCompiledTransform();
        XsltSettings xslSettings = new XsltSettings();
        xslSettings.EnableDocumentFunction = true;
        xslSettings.EnableScript = true;

        xsltTrans.Load(xslFile, xslSettings, resolver);

        XmlWriterSettings writerSettings = xsltTrans.OutputSettings;

        _xmlReaderSettings.XmlResolver = resolver;

        try
        {
            using (XmlWriter xw = XmlWriter.Create(outFile, writerSettings))
            {
                using (XmlReader xr = XmlReader.Create(inputfile, _xmlReaderSettings))
                {

                    if (_xslArgs != null)
                    {
                        xsltTrans.Transform(xr, _xslArgs, xw);
                    }
                    else
                    {
                        xsltTrans.Transform(xr, xw);
                    }
                }
            }

        }
        catch (XsltException xslex)
        {
            sResult = string.Format("Error: XSLT Exception - {0} - Line {1} - {2}", Path.GetFileName(xslFile), xslex.LineNumber, xslex.Message);
        }

0 个答案:

没有答案