SharePoint: render, rather than download, XML file

2019-09-01 16:29发布

I'm currently trying to move an XML/XSLT-based website into SharePoint. Basically, the existing site consists of a load of XML files, each of which references (via xml-stylesheet) an XSLT file, which transforms the XML into a full HTML file (including <html>, <head> and <body> etc.).

What I'm trying to do at the moment is just to dump the existing site into a SharePoint Document Library, let SharePoint control versioning, access rights etc, but continue to have IE render each XML file into complete HTML pages. However, when I try to view the XML file, SharePoint/IE just tries to download the source, rather than rendering it. How can I fix this?

(Also, any suggestions for a more-SharePointy way of doing this would be appreciated. I've tried using an XML Viewer web part but couldn't get it to render properly; it might be nice to turn each of these XML pages into SP Wiki pages, but that's a lot of work to do essentially by hand; a Page Viewer webpart has the same issue, in that it tries to download the file rather than display it.)

2条回答
一夜七次
2楼-- · 2019-09-01 16:39

Well, some more googling led me to the following:

http://code-journey.com/2011/01/08/sharepoint-2010-download-file-instead-of-opening-in-browser-pdf-xml-html-etc-x-download-options-header-trouble/

Basically SharePoint has its own HTTP header that tells IE8 to download a file rather than opening it. Unfortunately it's only an on/off option, so there's no choice to only change this for XML files.


But what I finally did was to render the XML into HTML on the server, using something like this.

查看更多
家丑人穷心不美
3楼-- · 2019-09-01 16:54

you have to create a custom webpart which extends from dataform webpart

http://blogs.msdn.com/b/joshuag/archive/2008/03/14/using-xslt-in-your-sharepoint-web-part.aspx

查看更多
登录 后发表回答