2

I have started into looking into the PnP samples into creating taxonomy. The samples are pretty basic and laborious, in that you have to write code for the taxonomy you are creating like so:

// Create a Content Type Information object
        ContentTypeCreationInformation newCt = new ContentTypeCreationInformation();
        // Set the name for the content type
        newCt.Name = "Contoso Document";
        //Inherit from oob document - 0x0101 and assign 
        newCt.Id = "0x0101009189AB5D3D2647B580F011DA2F356FB2";
        // Set content type to be avaialble from specific group
        newCt.Group = "Contoso Content Types";
        // Create the content type
        ContentType myContentType = contentTypes.Add(newCt);
        cc.ExecuteQuery();

I am looking for a solution where I can take the exported XML provisioning file for Site Columns and Content Types and feed it to a sample program which can basically replicate the logic of the provisioning engine. Sure I could write some logic to parse the XML files and do this via the CSOM, but I am specifically after an OOB solution which will be able to parse all the possible combinations of XML definitions for SharePoint schema.

I do not see why there shouldn't be a pathway to supporting the provisioning logic, simply because we are moving to CSOM-based provisioning.

Thanks in advance.

Here are some examples of XML definitions of SharePoint taxonomy:

Content Types

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="BaseContentTypes">
  </Module>

  <!-- Staff-->
  <ContentType ID='0x0100F92B529AD18F4D498737307175B60E37' Name='Staff' Group='Sukul.Demo' Description='' Overwrite='TRUE' Inherits='FALSE'>
    <FieldRefs>
      <FieldRef ID='{c042a256-787d-4a6f-8a8a-cf6ab767f12d}' Name='ContentType' Required='FALSE' Hidden='FALSE' />
      <FieldRef ID='{fa564e0f-0c70-4ab9-b863-0177e6ddd247}' Name='Title' Required='FALSE' Hidden='TRUE' ShowInNewForm='TRUE' ShowInEditForm='TRUE' />
      <FieldRef ID='{e1b2b669-2302-43ef-8e77-828f30fe5521}' Name='FirstName1' Required='TRUE' Hidden='FALSE' />
      <FieldRef ID='{3ac38149-6751-4f6c-b85e-09541a696fc7}' Name='LastName' Required='TRUE' Hidden='FALSE' />
      <FieldRef ID='{64a42df2-a554-48d1-a4bb-1e7781ca1769}' Name='EmailAddress' Required='FALSE' Hidden='FALSE' />
      <FieldRef ID='{2112affc-de2f-4d1f-847c-8daa72ef97a8}' Name='ContactPhone' Required='FALSE' Hidden='FALSE' />
      <FieldRef ID='{1615cd6e-7f8a-4494-a3a3-942e82dd53c8}' Name='IsStaffRoomLeader' Required='FALSE' Hidden='FALSE' />
      <FieldRef ID='{42b95a14-8366-4008-aa89-1dbb77a2b873}' Name='DateOfBirth' Required='FALSE' Hidden='FALSE' />
      <FieldRef ID='{ae05e3c0-5f0a-4e4d-80a7-1d02207da877}' Name='FullName1' Required='FALSE' Hidden='FALSE' />
    </FieldRefs>
  </ContentType>

  <!-- Guardian -->
  <ContentType ID='0x0100E24CA8452451C1448327FBDBF49A2A1C' Name='Guardian' Group='Sukul.Demo' Description='' Overwrite='TRUE' Inherits='FALSE'>
    <FieldRefs>
      <FieldRef ID='{c042a256-787d-4a6f-8a8a-cf6ab767f12d}' Name='ContentType' Required='FALSE' Hidden='FALSE' />
      <FieldRef ID='{fa564e0f-0c70-4ab9-b863-0177e6ddd247}' Name='Title' Required='FALSE' Hidden='TRUE' ShowInNewForm='TRUE' ShowInEditForm='TRUE' />
      <FieldRef ID='{e1b2b669-2302-43ef-8e77-828f30fe5521}' Name='FirstName1' Required='TRUE' Hidden='FALSE' />
      <FieldRef ID='{3ac38149-6751-4f6c-b85e-09541a696fc7}' Name='LastName' Required='TRUE' Hidden='FALSE' />
      <FieldRef ID='{2112affc-de2f-4d1f-847c-8daa72ef97a8}' Name='ContactPhone' Required='FALSE' Hidden='FALSE' />
      <FieldRef ID='{64a42df2-a554-48d1-a4bb-1e7781ca1769}' Name='EmailAddress' Required='FALSE' Hidden='FALSE' />
      <FieldRef ID='{ae05e3c0-5f0a-4e4d-80a7-1d02207da877}' Name='FullName1' Required='FALSE' Hidden='FALSE' />
      <FieldRef ID='{bfbf5341-21f0-4771-a1fd-548429abe30b}' Name='GuardianType' Required='TRUE' Hidden='FALSE' />
    </FieldRefs>
  </ContentType>

</Elements>

Fields

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="BaseColumns">5fb64256-6264-4b5d-997b-588c2bf42715
  </Module>
  <!--Room-->
  <Field Type="TaxonomyFieldType" Group="Sukul.Demo" DisplayName="Room" ShowField="Term1033" Required="FALSE" EnforceUniqueValues="FALSE" ID="{db8695a1-b73a-4caa-b3ba-5b287a90b3e8}" StaticName="SukulFieldsRoom"
         Name="Room" SourceID="{2B9FE58F-2C41-4403-950D-FFFCDA0ECB5E}"
         List="Lists/TaxonomyHiddenList" WebId="~sitecollection" Version="2">
    <Default></Default>
    <Customization>
      <ArrayOfProperty>
        <Property>
          <Name>SspId</Name>
          <Value xmlns:q1="http://www.w3.org/2001/XMLSchema" p4:type="q1:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">5fb64256-6264-4b5d-997b-588c2bf42715</Value>
        </Property>
        <Property>
          <Name>GroupId</Name>
        </Property>
        <Property>
          <Name>TermSetId</Name>
          <Value xmlns:q2="http://www.w3.org/2001/XMLSchema" p4:type="q2:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">f6d8e1b6-78c7-4f85-9773-3ba601ad0196</Value>
        </Property>
        <Property>
          <Name>AnchorId</Name>
          <Value xmlns:q3="http://www.w3.org/2001/XMLSchema" p4:type="q3:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">00000000-0000-0000-0000-000000000000</Value>
        </Property>
        <Property>
          <Name>UserCreated</Name>
          <Value xmlns:q4="http://www.w3.org/2001/XMLSchema" p4:type="q4:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</Value>
        </Property>
        <Property>
          <Name>Open</Name>
          <Value xmlns:q5="http://www.w3.org/2001/XMLSchema" p4:type="q5:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</Value>
        </Property>
        <Property>
          <Name>TextField</Name>
          <Value xmlns:q6="http://www.w3.org/2001/XMLSchema" p4:type="q6:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">{3c9d245c-f5fa-415d-ab9d-d41f47f267b2}</Value>
        </Property>
        <Property>
          <Name>IsPathRendered</Name>
          <Value xmlns:q7="http://www.w3.org/2001/XMLSchema" p4:type="q7:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</Value>
        </Property>
        <Property>
          <Name>IsKeyword</Name>
          <Value xmlns:q8="http://www.w3.org/2001/XMLSchema" p4:type="q8:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</Value>
        </Property>
        <Property>
          <Name>TargetTemplate</Name>
        </Property>
        <Property>
          <Name>CreateValuesInEditForm</Name>
          <Value xmlns:q9="http://www.w3.org/2001/XMLSchema" p4:type="q9:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</Value>
        </Property>
        <Property>
          <Name>FilterAssemblyStrongName</Name>
          <Value xmlns:q10="http://www.w3.org/2001/XMLSchema" p4:type="q10:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">Microsoft.SharePoint.Taxonomy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Value>
        </Property>
        <Property>
          <Name>FilterClassName</Name>
          <Value xmlns:q11="http://www.w3.org/2001/XMLSchema" p4:type="q11:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">Microsoft.SharePoint.Taxonomy.TaxonomyField</Value>
        </Property>
        <Property>
          <Name>FilterMethodName</Name>
          <Value xmlns:q12="http://www.w3.org/2001/XMLSchema" p4:type="q12:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">GetFilteringHtml</Value>
        </Property>
        <Property>
          <Name>FilterJavascriptProperty</Name>
          <Value xmlns:q13="http://www.w3.org/2001/XMLSchema" p4:type="q13:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">FilteringJavascript</Value>
        </Property>
      </ArrayOfProperty>
    </Customization>
  </Field>
  <Field Type="Note" DisplayName="SukulFieldsRoom_0" StaticName="SukulFieldsRoom0" Name="SukulFieldsRoom0" ID="{3C9D245C-F5FA-415D-AB9D-D41F47F267B2}" ShowInViewForms="FALSE" Required="FALSE"
         Hidden="TRUE" CanToggleHidden="TRUE" SourceID="{2B9FE58F-2C41-4403-950D-FFFCDA0ECB5E}" Overwrite="TRUE" />
  <!--DateOfBirth-->
  <Field Type="DateTime" DisplayName="DateOfBirth" Description="Date of Birth" Required="TRUE" EnforceUniqueValues="FALSE" Overwrite="TRUE" Indexed="FALSE" Format="DateOnly" Group="Sukul.Demo" FriendlyDisplayFormat="Disabled" ID="{42b95a14-8366-4008-aa89-1dbb77a2b873}" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="DateOfBirth" Name="DateOfBirth"></Field>
  <!-- AttendanceDateIn -->
  <Field Type="DateTime" DisplayName="AttendanceDateIn" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateTime" Group="Sukul.Demo" Overwrite="TRUE" FriendlyDisplayFormat="Disabled" ID="{bca57f3a-4257-4765-905f-0db32ffb3c8c}" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="AttendanceDateIn" Name="AttendanceDateIn" CalType="0" Version="1"></Field>
  <!--IsStaffRoomLeader-->
  <Field Type="Boolean" DisplayName="IsStaffRoomLeader" Description="Is Staff a Room Leader" EnforceUniqueValues="FALSE" Indexed="FALSE" Group="Sukul.Demo" ID="{1615cd6e-7f8a-4494-a3a3-942e82dd53c8}" Overwrite="TRUE" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="IsStaffRoomLeader" Name="IsStaffRoomLeader">
    <Default>0</Default>
  </Field>
  <!--GenderOfChild-->
  <Field Type="Choice" DisplayName="GenderOfChild" Description="Gender of child" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="RadioButtons" FillInChoice="FALSE" Group="Sukul.Demo" ID="{f7ac699d-93a9-42ed-a3c5-8e42e8b05c96}" Overwrite="TRUE" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="GenderOfChild" Name="GenderOfChild">
    <Default>Male</Default>
    <CHOICES>
      <CHOICE>Male</CHOICE>
      <CHOICE>Female</CHOICE>
    </CHOICES>
  </Field>
  <!--AttendanceDateOut-->
  <Field Type="DateTime" DisplayName="AttendanceDateOut" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateTime" Group="Sukul.Demo" FriendlyDisplayFormat="Disabled" ID="{c481e5cf-98fa-4595-8f79-9fe18398b6ae}" Overwrite="TRUE" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="AttendanceDateOut" Name="AttendanceDateOut" CalType="0" Version="1"></Field>
  <!--LastName-->
  <Field Type="Text" DisplayName="LastName" Required="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" Group="Sukul.Demo" ID="{3ac38149-6751-4f6c-b85e-09541a696fc7}" Overwrite="TRUE" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="LastName" Name="LastName"></Field>
  <!--FirstName-->
  <Field Type="Text" DisplayName="FirstName" Required="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" Group="Sukul.Demo" ID="{e1b2b669-2302-43ef-8e77-828f30fe5521}" Overwrite="TRUE" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="FirstName1" Name="FirstName1"></Field>
  <!--EmailAddress-->
  <Field Type="Text" DisplayName="EmailAddress" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" Group="Sukul.Demo" ID="{64a42df2-a554-48d1-a4bb-1e7781ca1769}" Overwrite="TRUE" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="EmailAddress" Name="EmailAddress"></Field>
  <!--ContactPhone-->
  <Field Type="Note" DisplayName="ContactPhone" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" NumLines="6" RichText="FALSE" Sortable="FALSE" Group="Sukul.Demo" ID="{2112affc-de2f-4d1f-847c-8daa72ef97a8}" Overwrite="TRUE" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="ContactPhone" Name="ContactPhone"></Field>
  <!--GuardianType-->
  <Field Type="TaxonomyFieldType" DisplayName="GuardianType" List="Lists/TaxonomyHiddenList" WebId="~sitecollection" Overwrite="TRUE" ShowField="Term1033" Required="TRUE" EnforceUniqueValues="FALSE" Group="Sukul.Demo" ID="{bfbf5341-21f0-4771-a1fd-548429abe30b}" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="GuardianType" Name="GuardianType" Version="1">
    <Default></Default>
    <Customization>
      <ArrayOfProperty>
        <Property>
          <Name>SspId</Name>
          <Value xmlns:q1="http://www.w3.org/2001/XMLSchema" p4:type="q1:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">5fb64256-6264-4b5d-997b-588c2bf42715</Value>
        </Property>
        <Property>
          <Name>GroupId</Name>
        </Property>
        <Property>
          <Name>TermSetId</Name>
          <Value xmlns:q2="http://www.w3.org/2001/XMLSchema" p4:type="q2:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">bfe6d355-4566-491a-8c57-fde0233e56a2</Value>
        </Property>
        <Property>
          <Name>AnchorId</Name>
          <Value xmlns:q3="http://www.w3.org/2001/XMLSchema" p4:type="q3:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">00000000-0000-0000-0000-000000000000</Value>
        </Property>
        <Property>
          <Name>UserCreated</Name>
          <Value xmlns:q4="http://www.w3.org/2001/XMLSchema" p4:type="q4:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</Value>
        </Property>
        <Property>
          <Name>Open</Name>
          <Value xmlns:q5="http://www.w3.org/2001/XMLSchema" p4:type="q5:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</Value>
        </Property>
        <Property>
          <Name>TextField</Name>
          <Value xmlns:q6="http://www.w3.org/2001/XMLSchema" p4:type="q6:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">{d2c22c6b-503c-4fae-b42c-da61b7e42e81}</Value>
        </Property>
        <Property>
          <Name>IsPathRendered</Name>
          <Value xmlns:q7="http://www.w3.org/2001/XMLSchema" p4:type="q7:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</Value>
        </Property>
        <Property>
          <Name>IsKeyword</Name>
          <Value xmlns:q8="http://www.w3.org/2001/XMLSchema" p4:type="q8:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</Value>
        </Property>
        <Property>
          <Name>TargetTemplate</Name>
        </Property>
        <Property>
          <Name>CreateValuesInEditForm</Name>
          <Value xmlns:q9="http://www.w3.org/2001/XMLSchema" p4:type="q9:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false</Value>
        </Property>
        <Property>
          <Name>FilterAssemblyStrongName</Name>
          <Value xmlns:q10="http://www.w3.org/2001/XMLSchema" p4:type="q10:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">Microsoft.SharePoint.Taxonomy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Value>
        </Property>
        <Property>
          <Name>FilterClassName</Name>
          <Value xmlns:q11="http://www.w3.org/2001/XMLSchema" p4:type="q11:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">Microsoft.SharePoint.Taxonomy.TaxonomyField</Value>
        </Property>
        <Property>
          <Name>FilterMethodName</Name>
          <Value xmlns:q12="http://www.w3.org/2001/XMLSchema" p4:type="q12:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">GetFilteringHtml</Value>
        </Property>
        <Property>
          <Name>FilterJavascriptProperty</Name>
          <Value xmlns:q13="http://www.w3.org/2001/XMLSchema" p4:type="q13:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">FilteringJavascript</Value>
        </Property>
      </ArrayOfProperty>
    </Customization>
  </Field>
  <Field Type="Note" DisplayName="GuardianType_0" StaticName="bfbf534121f04771a1fd548429abe30b" Name="bfbf534121f04771a1fd548429abe30b" ID="{d2c22c6b-503c-4fae-b42c-da61b7e42e81}" ShowInViewForms="FALSE" Required="FALSE" Overwrite="TRUE" Hidden="TRUE" CanToggleHidden="TRUE" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" />
  <!--FullName-->
  <Field Type="Calculated" DisplayName="FullName" EnforceUniqueValues="FALSE" Overwrite="TRUE" Indexed="FALSE" Format="DateOnly" LCID="1033" ResultType="Text" ReadOnly="TRUE" Group="Sukul.Demo" ID="{ae05e3c0-5f0a-4e4d-80a7-1d02207da877}" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="FullName1" Name="FullName1" Required="FALSE" Version="2">
    <Formula>=FirstName1&amp;" "&amp;LastName</Formula>
    <FieldRefs>
      <FieldRef Name="FirstName1" ID="{e1b2b669-2302-43ef-8e77-828f30fe5521}" />
      <FieldRef Name="LastName" ID="{3ac38149-6751-4f6c-b85e-09541a696fc7}" />
    </FieldRefs>
  </Field>
  <!--Date of Event-->
  <Field Type="DateTime" DisplayName="Date Of Event" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateTime" Overwrite="TRUE" Group="Sukul.Demo" FriendlyDisplayFormat="Disabled" ID="{dc0f6741-0705-48f2-9669-7c19a1f63eae}" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="Date_x0020_Of_x0020_Event" Name="Date_x0020_Of_x0020_Event">
    <Default>[today]</Default>
  </Field>
  <!--Start Datetime-->
  <Field Type="DateTime" DisplayName="Start DateTime" Required="FALSE" EnforceUniqueValues="FALSE" Overwrite="TRUE" Indexed="FALSE" Format="DateTime" Group="Sukul.Demo" FriendlyDisplayFormat="Disabled" ID="{afaa7c42-39de-44c8-8d09-6abd5e8f6750}" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="Start_x0020_DateTime" Name="Start_x0020_DateTime" CalType="0" Version="1"></Field>
  <!--End Datetime-->
  <Field Type="DateTime" DisplayName="End DateTime" Required="FALSE" EnforceUniqueValues="FALSE" Overwrite="TRUE" Indexed="FALSE" Format="DateTime" Group="Sukul.Demo" FriendlyDisplayFormat="Disabled" ID="{c2155dd9-d5dc-49ab-8ada-2cd336936ab7}" SourceID="{71873de0-8937-47ab-a03e-1a5a66dfd39a}" StaticName="End_x0020_DateTime" Name="End_x0020_DateTime" CalType="0" Version="1"></Field>

</Elements>
1

For fields you can achieve this quite easily, using either CSOM or SSOM, by feeding the field XML to AddFieldAsXml, roughly as follows:

web.Fields.AddFieldAsXml(oneFieldDefinition.OuterXml, false, Microsoft.SharePoint.Client.AddFieldOptions.DefaultValue);

I'm not aware of any similar capability for content types, though.

  • That's great feedback! I will try this out and update the thread later.. – Shailen Sukul Nov 4 '14 at 23:47

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.