有一个包含以下内容的 XSL 文件:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:XQHeaderFunc="java:com.sonicsw.xq.service.xform.HeaderExtension"
xmlns:saxon="http://saxon.sf.net/"
exclude-result-prefixes="XQHeaderFunc saxon">
<saxon:script language="java" implements-prefix="XQHeaderFunc" src="java:com.sonicsw.xq.service.xform.HeaderExtension" />
稍后在文件中:
<xsl:variable name="processId" select="XQHeaderFunc:getProperty(XQHeaderFunc:new(),'processId',-1)" />
当我现在尝试进行转换时,出现此错误:
找不到与命名空间“java:com.sonicsw.xq.service.xform.HeaderExtension”关联的脚本或扩展对象。
这是我不关心的一些 SonicMQ 特定的东西。有没有办法我可以以某种方式忽略它?
我目前做这样的转换:
var readerSettings = new XmlReaderSettings
{
ConformanceLevel = ConformanceLevel.Document,
IgnoreWhitespace = true,
IgnoreComments = true,
IgnoreProcessingInstructions = true,
CheckCharacters = true,
};
var writerSettings = new XmlWriterSettings
{
Encoding = Encoding.UTF8,
ConformanceLevel = ConformanceLevel.Document,
NewLineHandling = NewLineHandling.Replace,
OmitXmlDeclaration = false,
NewLineChars = "\r\n",
Indent = true,
IndentChars = " ",
CloseOutput = false,
};
var xsl = new XslCompiledTransform(System.Diagnostics.Debugger.IsAttached);
using (var stylesheet = XmlReader.Create(xslFile, readerSettings))
xsl.Load(stylesheet);
using (var result = new MemoryStream())
{
using (var xml = XmlReader.Create(xmlFile, readerSettings))
using (var xmlWriter = XmlWriter.Create(result, writerSettings))
{
xsl.Transform(xml, xmlWriter);
}
// Deal with result
}