1
我不知道XSL模板非常好,因爲我只在兩個小時前第一次看到一個模板。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
和title
參數。但是,由於某種原因,它們沒有出現在打印輸出中。
但是,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
參數沒有顯示在輸出中的原因嗎?