SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to fetch data from the list (which I am getting in XML) and then I need to apply the XML data to my XSLT so that it can produce HTML output.

I tried using SPUtility.GetGenericSetupPath to get the XSLT which resides in 14 hive but SPUtility.GetGenericSetupPath doesn't supported in Sandbox web parts.

I got that I will be uploading my XSLT somewhere into SharePoint Library, but the real question is How will I consume it?

SPUtility.GetGenericSetupPath to get the XSLT isn't working in Sandbox.

How will I get the path of XSLT?

This is what I have done with Farm Web Part, now I'm converting it into Sandbox Web Part.

            //Transform XML To HTML using ContactList.XSLT
            XslCompiledTransform XMLTrnsfrm = new XslCompiledTransform();

Any other solution in mind guys?

share|improve this question
up vote 1 down vote accepted

In a sandboxed solution you'll not be able to read from the file system so you need to put the XSLT file into a SharePoint document library then read it like this:

var file = web.GetFile(pathToXslt);
var bytes = file.OpenBinary();
var stream = new MemoryStream(bytes);
var reader = new XmlTextReader(stream);
var XMLTransfrm = new XslCompiledTransform();
share|improve this answer
When you say pathToXslt, you mean the full path to the xslt? like ""; ?? – NICK Oct 8 '12 at 7:46
Also, file.OpenBinaryStream() is not working, OpenBinaryStream is throwing an error because It's not Available in Sandboxed Solutions. – NICK Oct 8 '12 at 7:59
It can be either the full path, server relative /sites/MySite/doclib/myxslt.xslt or site relative doclib/myxslt.xslt – Per Jakobsen Oct 8 '12 at 8:02
It's throwing Request for the permission of type 'System.Net.WebPermission, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. – NICK Oct 8 '12 at 8:07
What I did is just, XMLTrnsfrm.Load(""); – NICK Oct 8 '12 at 8:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.