Thursday, 1 December 2011

SharePoint 2010 - How to Get XML Sample Data for Debugging Web Parts that support XSL transform customization (e.g. Search and Content Query Web Parts)

XSLT is the preferred technology for customizing the visual output of SharePoint Web parts (primarily as it is standards-based and non-proprietary). However, there is absolutely no XSLT debugging support provided within the SharePoint environment (this is surprising as it is so pervasive). With these limitations in mind, XSLT should ideally be developed outside of SharePoint in a proper IDE that supports XSL debugging such as Visual Studio 2010 or Altova's XMLSpy.

However, debugging XSLT requires a data source (in the form of XML sample data) as input to the XSL transform. The simplest way to get a sample input XML file provided by SharePoint for a XSL-enabled web part is to do the following:

1) Open ContentQueryMain.xsl and find the XSL that looks like the following:

<xsl:template match="/">
  <xsl:call-template name="OuterTemplate"> </xsl:call-template></xsl:template>

Replace this XSL with the following so that it outputs all xml rather than just applying the OuterTemplate xsl template :
<xsl:template match="/">
  <xmp><xsl:copy-of select="*" /></xmp>
</xsl:template>

To avoid modifying system files like ContentQueryMain.xsl, you can make a copy the ContentQueryMain.xsl e.g. ContentQueryMainDebug.xsl and point your CQWP to the Content QueryMainDebug.xsl file instead - using the MainXslLink property of the Content Query Web Part (defined in the .webpart file).

2) View Source on the page and locate the block of XML that has been output by your web part.

3) Save it as a text file and use it as input into your favourite XSL development tool.

DDK

11 comments:

Mike said...

XML features in sharepoint workflows: HarePoint Workflow Extensions ( http://www.harepoint.com/Products/HarePointWorkflowExtensions/ ) – about 200 new workflow activities, including free ones.

Mike said...
This comment has been removed by the author.
Mike said...
This comment has been removed by the author.
russell said...

Why do you keep removein comments?

Yes done - Best Professional On Demand Home Service Provider in Jaipur said...

Thanks for sharing this information.
Yes Done is the best online site for on demand home services, professional service providers in Jaipur, Rajasthan. We are providing top services like carpenter, cleaning, TV, best pest control services in Jaipur, ro repair service in Jaipur, ac repair service in Jaipur online by Yes Done is there for services at your doorstep in Jaipur, Rajasthan. For more service visit our website. For more services visit our website.

GIEC Global - Best Migration Agent Melbourne & Education Consultant in Melbourne, Australia said...

It's a great blog, shares a piece of good information.

GIEC Global is the leading education and migration consultants in Australia. We are top Education consultants in Melbourne, Sydney, Perth, Brisbane, Adelaide and Australia. We are best education consultants for Canada in Australia. We also helps people in studying in USA and have been awarded as education consultants for USA in Melbourne and education consultant for UK in Australia.

GIEC Global - Best Migration Agent Melbourne & Education Consultant in Melbourne, Australia said...

The awesome blog shares good information with everyone. I will bookmark it in the future.

France Education Consultants in Australia is GIEC Global. We are top Education consultants for Norway in Melbourne, Sydney, Perth, Brisbane, Adelaide and Australia. We are best education consultants for Netherlands in Australia. We also helps people in studying in Ireland and have been awarded as education consultants for Ireland in Melbourne and education consultant for Finland in Australia.

GIEC Global - Best Migration Agent Melbourne & Education Consultant in Melbourne, Australia said...

Nice Blog, worth reading it. I have also bookmarked it for the future.

If you are looking to Work in Australia , Work in Canada, Work in USA, Work in UK, or Work in Ireland then GIEC Global will be the best consultant for you in Australia.

GIEC Global - Best Migration Agent Melbourne & Education Consultant in Melbourne, Australia said...

It's a really good blog and I am in love while reading it.

If you are looking to migrate to Australia , Migrate to Canada, Migrate to USA, Migrate to UK, Migrate to France, or Migrate to Ireland then GIEC Global will be the best consultant for you in Australia.

GIEC Global - Best Migration Agent Melbourne & Education Consultant in Melbourne, Australia said...

Good One. Worth reading it once.

If you are looking to Visit to Australia , Visit to Canada, Visit to USA, or Visit to UK then GIEC Global will be the best consultant for you in Australia.

Apparrant Technologies - Web and Mobile Application Development Company said...

Thank you for sharing this valuable information.

Apparrant is the leading UX UI Design agency having experienced designers and developers working throughout the year on important and life changing products. We have been awarded as top UI UX Design agency in India by multiple agencies. If you are looking for best UX Design Agency in Noida, UI UX Design Agency in Faridabad, and UX UI Design Company in Delhi then Apparrant is best for you.