Friday, November 9, 2012

Cannot recognize the XML namespace of this Web Part

Hi All,


When provisioning pages (e.g. default.aspx) using a feature, you can add default webparts using <AllUsersWebPart>
Keep in mind you have two types of webparts, v2 en v3. When provisioning v2: you should use the following syntax:
<AllUsersWebPart WebPartZoneID="FooterLeft" WebPartOrder="2">                
<![CDATA[                             
<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">                  
...
</WebPart>                
]]>            
</AllUsersWebPart>
and with v3:
<AllUsersWebPart WebPartZoneID="FooterLeft" WebPartOrder="5">                
<![CDATA[                    
<webParts>                      
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">   ... 
</webPart>                    
</webParts>                
]]>            
</AllUsersWebPart>
Look at the difference in attributes of WebPart-tag AND the extra <webParts> tag in the v3-version. If you add <webParts> around the <webPart>-declaration in the v2-version, you could receive the error: Cannot recognize the XML namespace of this Web Part.

No comments:

Post a Comment