如原始问题所述,使用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);
}