0

I exported an xml viewer web part with Get-PnPWebPartXml and expected that I could copy-paste this to a pnp provisioning template. Looks like that the schema is different and instead of this (example when I export a list view):

<webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
    <metaData>
      <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
      <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="ShowWithSampleData" type="bool">False</property>
        <property name="Default" type="string" />
        <property name="NoDefaultStyle" type="string" null="true" />
      ...
      </properties>
    </data>
  </webPart>
</webParts>

I get this:

<WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">
  <Title>services</Title>
  <FrameType>None</FrameType>
  <Description>Transforms XML data using XSL and shows the results.</Description>
  <IsIncluded>true</IsIncluded>
  <ZoneID>Left</ZoneID>
  <PartOrder>0</PartOrder>
....
</WebPart>

Edit: I tried to retype the web part, no success:

      <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
        <metaData>
          <type name="Microsoft.SharePoint.WebPartPages.XmlWebPart, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
          <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
        </metaData>
        <data>
          <properties>
            <property name="XMLLink" xmlns="http://schemas.microsoft.com/WebPart/v2/Xml" type="string">mysite/test.xml</property>
            <property name="XSLLink" xmlns="http://schemas.microsoft.com/WebPart/v2/Xml" type="string">mysite/test.xsl</property>
            <property name="Title" type ="String">services</property>
            <property name="FrameType" type ="String">None</property>
            <property name="Description" type ="String">Transforms XML data using XSL and shows the results.</property>
            <property name="IsIncluded" type ="bool">True</property>
            <property name="FrameState" type ="String">Normal</property>
            <property name="AllowRemove" type ="bool">False</property>
            <property name="AllowZoneChange" type ="bool">False</property>
            <property name="AllowMinimize" type ="bool">False</property>
            <property name="AllowConnect" type ="bool">False</property>
            <property name="AllowEdit" type ="bool">False</property>
            <property name="AllowHide" type ="bool">False</property>
            <property name="IsVisible" type ="bool">Frue</property>
          </properties>
        </data>
      </webPart>

I get an error saying 2 times, and I think, this is the xsl and the xml link, because I get the same when I remove all the other properties:

The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

So, can someone please send a working example for the XML Web part?

0

So, for everyone who's interested, I found a workaround here: https://github.com/SharePoint/PnP-Sites-Core/issues/869

Should I not interpret it 100% correctly, comments are welcome. Looks like Sharepoint has 2 type of webparts with 2 different schema's. To make the 2nd version working in the PnP template, the <webParts> tag should be omitted:

              <pnp:WebPart Title="Tasks" Row="2" Column="1">
                <pnp:Contents>
                 <WebParts> <!--- remove -->
                    <WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">
                      <Title>services</Title>
                      <FrameType>None</FrameType>
                      <Description>Transforms XML data using XSL and shows the results.</Description>
                      <IsIncluded>true</IsIncluded>
  ...all other elements from the webpart...
                    </WebPart>
                  </WebParts> <!---  remove  -->
                </pnp:Contents>
              </pnp:WebPart>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.