1
有一個包含有啓動的XSL文件如下:使XslCompiledTransform忽略腳本
<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)" />
當我嘗試做一個轉變,現在我得到這個錯誤:
Cannot find a script or an extension object associated with namespace '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
}
應該發生什麼而不是腳本功能? –
可能沒有什麼,但如果我可以注入一個值,那麼我可以插入一個硬編碼的字符串,例如。 – Svish
預處理xslt(可能帶有另一個xslt),以您想要的方式刪除/重寫樣式表... – Pawel