0

I would like to create a smart way to manage large templates with as less manual work as possible.

So, I created a small script to export different parts of a site collection like:

$parts = "Lists","Navigation","SiteSecurity"
ForEach ($part in $parts) {
get-pnpprovisioningtemplate -Out "C:\temp\$part.xml" -Handlers $part -Force -NobaseTemplate
}

The plan is to include all these in a master template out of the box with xinclude.

The problem is that the exported template contains the complete schema. The exported navigation looks like this:

<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2018/07/ProvisioningSchema">
  <pnp:Preferences Generator="OfficeDevPnP.Core, Version=3.7.1903.0, Culture=neutral, PublicKeyToken=5e633289e95c321a" />
  <pnp:Templates ID="CONTAINER-TEMPLATE-121E97A797D04B6E9AB496DB8B14C5AD">
    <pnp:ProvisioningTemplate ID="TEMPLATE-121E97A797D04B6E9AB496DB8B14C5AD" Version="1" BaseSiteTemplate="GROUP#0" Scope="RootSite">
      <pnp:Navigation AddNewPagesToNavigation="true" CreateFriendlyUrlsForNewPages="true">
        <pnp:GlobalNavigation NavigationType="Structural">
          <pnp:StructuralNavigation RemoveExistingNodes="false" />
        </pnp:GlobalNavigation>
        <pnp:CurrentNavigation NavigationType="StructuralLocal">
              <!---Navigation comes here--->
          </pnp:StructuralNavigation>
        </pnp:CurrentNavigation>
      </pnp:Navigation>
    </pnp:ProvisioningTemplate>
  </pnp:Templates>
</pnp:Provisioning>

So, when I try to include this file:

<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Navigation.xml"/>

This fails the PnP engine validation. When I strip out the xml and keep the pnp:Navigation node, inclusion works fine.

My question is, what is the easiest way to use the templates exported by the PnP engine in a master template? Is it possible to either include only the relevant part of the file (this would be the best) or runtime strip out the rest during/after export?

Your Answer

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

Browse other questions tagged or ask your own question.