我不太了解 XSL 模板,因为我在两个小时前才第一次看到一个。
我有以下模板:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:FormData="ext:FormVal"
xmlns:FormUrl="ext:UrlFinder"
>
<xsl:param name="note"/>
<xsl:param name="title"/>
<xsl:template match="/">
<html>
<head>
<title>EW Email Notification- File Note insertion Failed</title>
</head>
<body>
<p>
Failed to insert File note for form with refrence - <xsl:value-of select="FormData:get_RefFormId()" /> <br/>
<a>
<xsl:attribute name="href">
<xsl:value-of select="FormUrl:get_RootUrl()"></xsl:value-of>FormAction/ViewForm?formId=<xsl:value-of select="FormData:get_FormId()"></xsl:value-of>
</xsl:attribute>Click here </a> to open the form.
</p>
<p>
Please insert this file note manually.
</p>
<p>
<h3>
Title:
</h3>
<out> <xsl:value-of select="$title"></xsl:value-of>
</out>
</p>
<p>
<h3>
Note:
</h3>
<xsl:value-of select="$note"></xsl:value-of>
</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
大部分都是别人写的。我添加了note
andtitle
参数。但是,由于某种原因,它们没有出现在打印输出中。
但是,FormData:get_FormId()
有效。
我正在传递这样的变量:
dictionary["note"] = note;
dictionary["title"] =title;
dictionary["ext:FormVal"] = formVal;
dictionary["ext:UrlFinder"] = urlFinder;
var objxslt = new XslCompiledTransform();
objxslt.Load(Helper.GetEmbeddedXmlResource(templateAssembly, templateName));
var xmldoc = new XmlDocument();
xmldoc.AppendChild(xmldoc.CreateElement("DocumentRoot"));
XPathNavigator xpathnav = xmldoc.CreateNavigator();
var xslarg = new XsltArgumentList();
foreach (DictionaryEntry entry in dictionary)
{
xslarg.AddExtensionObject(entry.Key.ToString(), entry.Value);
}
var emailbuilder = new StringBuilder();
var xmlwriter = new XmlTextWriter(new System.IO.StringWriter(emailbuilder));
objxslt.Transform(xpathnav, xslarg, xmlwriter, null);
var xemaildoc = new XmlDocument();
xemaildoc.LoadXml(emailbuilder.ToString());
XmlNode titlenode = xemaildoc.SelectSingleNode("//title");
string subjecttext = titlenode.InnerText;
XmlNode bodynode = xemaildoc.SelectSingleNode("//body");
string bodytext = bodynode.InnerXml;
该变量bodytext
包含所有模板,但我希望打印参数的地方有空白。
谁能帮我确定note
和title
参数未显示在输出中的原因?