My code behind code from the aspx webpage uses a transform.xsl to do some custom xslt transformation.
Scenario 1: Try to get the file from the _layouts folder.
SPWeb web = SPContext.Current.Web; SPFile file = web.GetFile(@"/layouts/MyFeature/transform.xsl");
Note : The file is accesible on this url http://mysite:8080/_layouts/MyFeature/transform.xsl when using the browser.
Scenario 2: Try to get the file from the current (http://mysite:8080/MyFeature/MyPage.aspx) url.
SPWeb web = SPContext.Current.Web; SPFile file = web.GetFile(@"transform.xsl");
SPFile file = web.GetFile(@"MyFeature/transform.xsl");
SPFile file = web.GetFile(@"/MyFeature/transform.xsl");
All scenarios fail, how to solve this?
The 'transform.xsl' is now located at 'MyFeature/transform.xsl' and I've followed the tip from Anders Rask, and my code looks like this now:
SPWeb web = SPContext.Current.Web; XslCompiledTransform transformer = new XslCompiledTransform(); XsltSettings settings = new XsltSettings(true, true); string xslLocation = web.Url + "/FormWrapper/transform.xsl"; transformer.Load(xslLocation, settings, GetResolverWithDefaultCredentials()); // Do XSLT transform...