views:

276

answers:

1

Hi, I know it cud be quite simple questions for most of you. But I am not able to load xsl file from sharepoint document library.

i m trying to do this

getXSL = Server.MapPath("//Documents/myxsl.xslt");

  XslCompiledTransform xslt = new XslCompiledTransform();


         xslt.Load(getXSL);

but if i m doing like this it is taking it as inetpub/wss/VirtualDirectories/80.... I want it to refer to my Document library where i have uploaded my xslt.Any one is having idea how to achieve this?

A: 

You should be using the SharePoint API to access the document library, not the standard ASP.NET object model.

You'd want something like (assuming you are running this from a web part, and have an SPContext object handy)

SPFile spXslt = SPContext.Current.Web.Lists["Documents"].Items["myxsl.xslt"].File;

From here you can stream the contents of the SPFile and use it with the XML object model.

OedipusPrime
can you tell me how to do this...I tried yours and then added this Stream feedXSL = spXslt.OpenBinaryStream();XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load(getXSL);But its showing error.....
TSSS22
What is the error?
OedipusPrime
There are basicaly two errors....one Error 3 The best overloaded method match for 'System.Xml.Xsl.XslCompiledTransform.Load(System.Xml.XmlReader)' has some invalid arguments Error 4 Argument '1': cannot convert from 'System.IO.Stream' to 'System.Xml.XmlReader' Error 1 The best overloaded method match for 'Microsoft.SharePoint.SPListItemCollection.this[int]' has some invalid arguments Error 2 Argument '1': cannot convert from 'string' to 'int' These errors in your 2 lines....
TSSS22