Converting Section Collection Fields

Section collection fields in certain widgets will fail to work after conversion unless a small modification is made after export from the legacy publication. The easiest way to ensure that this modification is made in all required places is to apply the following XSL transformation to all syndication files exported from the legacy publication before they are imported to the new blueprint publication:

<xsl:stylesheet version="1.0"
                xmlns:ct="http://xmlns.escenic.com/2009/import"
                xmlns="http://xmlns.escenic.com/2009/import"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                exclude-result-prefixes="xsl ct">
  <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
  <xsl:strip-space elements="*"/>

  <xsl:variable name="heading_widget" select="'widget_heading'"/>
  <xsl:variable name="headingWidgetLegacySectionField" select="'sectionselection'"/>
  <xsl:variable name="headingWidgetNewSectionField" select="'contentsectionselection'"/>
  <xsl:variable name="headingWidgetPublicationField" select="'publication'"/>

  <xsl:variable name="searchComponent_widget" select="'widget_searchComponent'"/>
  <xsl:variable name="searchComponentWidgetLegacySectionField" select="'targetsection'"/>
  <xsl:variable name="searchComponentWidgetNewSectionField" select="'srcresultsection'"/>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
      <xsl:choose>
        <xsl:when test="current()/@type = $heading_widget">
          <xsl:if test="not(./ct:field[@name = $headingWidgetNewSectionField]) and
                        ./ct:field[@name = $headingWidgetLegacySectionField]">
            <field name="{$headingWidgetNewSectionField}">
              <title><xsl:value-of select="./ct:field[@name = $headingWidgetLegacySectionField]/ct:value"/></title>
              <value>
                <xsl:value-of select="./ct:field[@name = $headingWidgetLegacySectionField]/ct:section-ref/@unique-name"/>
              </value>
            </field>
          </xsl:if>
          <xsl:variable name="publicationName"
                        select="./ct:field[@name = $headingWidgetLegacySectionField]/ct:section-ref/@publication-name"/>
          <xsl:if test="not(./ct:field[@name = $headingWidgetPublicationField]) and $publicationName != ''">
            <field name="{$headingWidgetPublicationField}">
              <title><xsl:value-of select="$publicationName"/></title>
              <value><xsl:value-of select="$publicationName"/></value>
            </field>
          </xsl:if>
        </xsl:when>
        <!--Since 'Search box' is the default view the view field might not be present if not selected.-->
        <xsl:when test="current()/@type = $searchComponent_widget">
          <xsl:if test="not(./ct:field[@name = $searchComponentWidgetNewSectionField]) and
                        ./ct:field[@name = $searchComponentWidgetLegacySectionField]">
            <field name="{$searchComponentWidgetNewSectionField}">
              <title><xsl:value-of select="./ct:field[@name = $searchComponentWidgetLegacySectionField]/ct:value"/></title>
              <value>
                <xsl:value-of select="./ct:field[@name = $searchComponentWidgetLegacySectionField]/ct:section-ref/@unique-name"/>
              </value>
            </field>
          </xsl:if>
        </xsl:when>
      </xsl:choose>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>