Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint Web部件代码隐藏中的XML文档_Sharepoint_Xslt_Resources_Web Parts - Fatal编程技术网

Sharepoint Web部件代码隐藏中的XML文档

Sharepoint Web部件代码隐藏中的XML文档,sharepoint,xslt,resources,web-parts,Sharepoint,Xslt,Resources,Web Parts,我正在c#sharepoint Web部件代码中加载XSLT文件,如下所示: string path = context.Request.MapPath("/_layouts/RSSWeatherXSL.xsl"); XslTransform trans = new XslTransform(); trans.Load(path); // loading xsl file XSLT文件相当大,大约有134行 我需要引用XSLT中的图像,代码隐藏程序将生成该图像的路径 SPW

我正在c#sharepoint Web部件代码中加载XSLT文件,如下所示:

  string path = context.Request.MapPath("/_layouts/RSSWeatherXSL.xsl");
   XslTransform trans = new XslTransform();
     trans.Load(path); // loading xsl file
XSLT文件相当大,大约有134行

我需要引用XSLT中的图像,代码隐藏程序将生成该图像的路径

SPWeb currentWeb = SPControl.GetContextWeb(Context);
2.Type currentType = this.GetType();
3.string classResourcePath = SPWebPartManager.GetClassResourcePath(currentWeb, currentType);
我怎么能这样做? 谢谢,我的建议是:

string path = context.Request.MapPath("/_layouts/RSSWeatherXSL.xsl");

XmlDocument styledocument = new XmlDocument();
styledocument.Load(path);

XmlNode imagepath = styledocument.DocumentElement.AppendChild(styledocument.CreateElement("xsl:variable", "http://www.w3.org/1999/XSL/Transform"));

XmAttribute varname = imagepath.Attributes.Append(styledocument.CreateAttribute("name"));
varname.Value = "imagepath_1";

XmAttribute varselect = imagepath.Attributes.Append(styledocument.CreateAttribute("select"));
varselect.Value = "'here_goes_your_generated_path_in_single_quotes'";

// add more <xsl:variable /> nodes as needed

XslCompiledTransform trans = new XslCompiledTransform();
trans.Load(styledocument);
string path=context.Request.MapPath(“/_layouts/rssweetherxsl.xsl”);
XmlDocument styledocument=新的XmlDocument();
加载(路径);
XmlNode imagepath=styledocument.DocumentElement.AppendChild(styledocument.CreateElement(“xsl:variable”,”http://www.w3.org/1999/XSL/Transform"));
XmAttribute varname=imagepath.Attributes.Append(styledocument.CreateAttribute(“name”));
varname.Value=“imagepath_1”;
XmAttribute varselect=imagepath.Attributes.Append(styledocument.CreateAttribute(“select”);
varselect.Value=“'here\u goes\u your\u generated\u path\u in\u single\u quotes';
//根据需要添加更多节点
XslCompiledTransform trans=新的XslCompiledTransform();
事务加载(样式文档);

希望这能为您带来好处。

如果您不坚持使用.NET 1.0或1.1,您应该使用XslCompiledTransform而不是XslTransform。