I've created some custom List Definitions (aka List Templates) and am provisioning List Instances of them into my site. I am then provisioning Pages (Wiki/WebPartPages) that refer to the lists/views that I've setup. I am trying to do this using the element and then specify only the properties I want to change, rather than exporting a (which isn't localizeable). I can work with the Title property fine, however, when I try to specify the XslLink property, my web part will not provision correctly:
<View List="Lists/MyList" BaseViewID="105" WebPartZoneID="wpz" ID="g_6BFC14DC_62A4_4512_A360_EB4A0FC4DBD1"> <![CDATA[ <webParts> <webPart xmlns="http://schemas.microsoft.com/WebPart/v3"> <metaData> <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=126.96.36.199, Culture=neutral, PublicKeyToken=71e9bce111e9429c" /> <importErrorMessage>Cannot import this Web Part.</importErrorMessage> </metaData> <data> <properties> <property name="Title" type="string">Me</property> <property name="XslLink" type="string">~site/Assets/xsl/my.xsl</property> </properties> </data> </webPart> </webParts> ]]> </View>
For troubleshooting purposes, when I hard code the server relative url to my site (rather than using the "~site" reference), it also does not work. I check the contents of the page (using ?contents=1) and my web part is shown there, but likely as an "ErrorWebPart". I check the ULS logs and I get a vague "unexpected error" with DesignText and SourcePreabmle:DWP references.
Again, all this works fine if all I customize is the Title property, which makes me think my markup within the CDATA is correct. I've confirmed that the XslLink property (exposed via the DataFormWebPart from which XsltListViewWebPart ultimately derives) is, in fact, a string using ILSpy.
This also works fine if I get the content - using the "Save site as a template" functionality and extracting this page's contents into my feature.
Do I maybe need to use the old <WebPart> syntax instead of the newer <webParts>? Based on what I see in the Blog site template onet.xml (SiteTemplates\Blog\Xml\Onet.xml), it looks like the newer <webParts> is appropriate.
I see this in both a Sandboxed and Farm solution scenario.
thanks in advance!