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?


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();
  • When you say pathToXslt, you mean the full path to the xslt? like "mysharepointsite.com/sites/doclib/myxslt.xslt" ??
    – 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 http://mysharepointsite.com/sites/MySite/doclib/myxslt.xslt, server relative /sites/MySite/doclib/myxslt.xslt or site relative doclib/myxslt.xslt 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("mysharepointsite.com/sites/MySite/doclib/myxslt.xslt");
    – NICK
    Oct 8 '12 at 8:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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