Generate clean HTML in data form web part

A data form web part generated complicated HTML and sometimes creates problem for the designers. When you look into generated HTML you can notice some attributes we don’t want to appear in the markup.

<div style="margin: 0px auto; padding: 0px; width: 800px;" xmlns:ddwrt2="urn:frontpage:internal" xmlns:sharepoint="Microsoft.SharePoint.WebControls" xmlns:__designer="" xmlns:asp="" xmlns:d="" xmlns:x="">

I know you hate them, but I have good news. You can get rid of these very easy. All you need to do is to go to stylesheet declaration and modify value for exclude-result-prefixes like this: ddwrt asp __designer xsl msxsl SharePoint ddwrt2 d x.

<xsl:stylesheet xmlns:x="" xmlns:d="" version="1.0" exclude-result-prefixes="ddwrt asp __designer xsl msxsl SharePoint ddwrt2 d x" xmlns:ddwrt="" xmlns:asp="" xmlns:__designer="" xmlns:xsl="" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">

Also, you need to be sure you don’t have namespaces declared on template level. Put all namespaces in stylesheet declaration and remove them, if you have, from template declarations.

I did not try yet, but you probably can apply the same thing to XSLT list view web part, if you customize XSLT, as what I described above is XSLT related. But I leave it up to you to try.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s