问题
Lately I've been doing a lot of custom styling in SharePoint by modifying the XSL used to display various web parts. Knowing what the actual XML looks like, including which elements have actual values, really helps when working in the XSL. I've discovered a way to show this XML when using Ontolica web parts, but not when I'm using the default web parts included with SharePoint.
So, is there a way to do this, either programmatically or simply by adding a parameter to the URL? I could really use a tool like this and would be interested in developing one as OSS if I could determine if it's possible.
回答1:
As Ryan has alluded to, not all (in fact hardly any) use XML/XSLT to render their output. It's a complete mix including hard-coding, CAML, as well as XSLT depending on the web part. So you won't be able to reliably approach the problem this way.
However there is a toolkit called ARF by Vincent Rothwell which contains its own controls to render SharePoint output using XML/XSLT. It's designed for publishing sites but states that it works under WSS as well. The source code is also available so you can either enhance what's there or extend the toolkit with your own controls. I would strongly recommend researching this as Vincent has a great blog and seems to know his stuff.
回答2:
You can use this simple XSL template to dump the input XML:
<xsl:template match="/">
<xsl:copy-of select="/" />
</xsl:template>
回答3:
Although the Data View web part does - many of the built in web parts will not use any form of XML/XSLT to render output.
Another option would be to use some javascript/jquery to modify the output from the built in web parts to suit - Christophe has some great articles on this.
来源:https://stackoverflow.com/questions/1384713/how-to-display-xml-returned-by-sharepoint-for-web-parts