Transforming Configuration
The ConfigurationTransformationPackageFragmentInstaller can execute XSL transformations on the Experience Management configuration file (~/App_Data/Composite/Composite.config), enabling developers to make any desired changes to the configuration.
Different XSLT files can be specified for the install and uninstall scenarios and the files are located as normal files in the package's ZIP file.
<mi:Add installerType="Composite.Core.PackageSystem.PackageFragmentInstallers.ConfigurationTransformationPackageFragmentInstaller, Composite" uninstallerType="Composite.Core.PackageSystem.PackageFragmentInstallers.ConfigurationTransformationPackageFragmentUninstaller, Composite"> <Install xsltFilePath="~\Composite.config\Install.xsl" /> <Uninstall xsltFilePath="~\Composite.config\Uninstall.xsl" /> </mi:Add>
It is important to note that the XSLT is handed the entire Experience Management configuration file, and it is the responsibility of the XSLT to output a new valid and complete Experience Management configuration file.
The <mi:Add> element should include Install and Uninstall elements for install and unistall configuration transformation files respectively.
Each element has one attribute:
xsltFilePath: A tilde-based path that points to a transformation file in the package's ZIP file.
The following XSLT is an example of an install transformation that would add a new ‘PackageThingy’ tag to the Form UI language.
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="Channel[@name='AspNet.Management']/Namespaces/Namespace[@name='http://www.composite.net/ns/management/bindingforms/internal.ui.controls.lib/1.0']/Factories"> <Factories> <xsl:apply-templates select="@* | node()"/> <!-- here we install a new element, if it hasn't been installed earlier --> <xsl:if test="count(add[@name='PackageThingy'])=0"> <add userControlVirtualPath="~/PackageThingy.ascx" cacheCompiledUserControlType="false" type="PackageThingy.Sample, PackageThingy" name="PackageThingy" /> </xsl:if> </Factories> </xsl:template> </xsl:stylesheet>
The following XSLT is an example of an uninstall transformation that would remove the ‘PackageThingy’ tag.
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="Channel[@name='AspNet.Management']/Namespaces/Namespace[@name='http://www.composite.net/ns/management/bindingforms/internal.ui.controls.lib/1.0']/Factories/add[@name='PackageThingy']"> <!-- no copy = remove the element matching the template --> </xsl:template> </xsl:stylesheet>
Note: This fragment installer allows you to update configuration in Composite.config.