Creating a custom import package
To create a custom import package, interact with the Packaging API in the Tridion.ContentManager.ImportExport.Packaging namespace, documented in the Core Service API reference.
Procedure
- From your custom code, reference the .NET assembly called Tridion.ContentManager.ImportExport.Client.dll. You can find this assembly, with its associated file, in the folder %TRIDION_HOME%\bin\client\ImportExport\.
- Use the
Packageclass to create or modify a package. For example, the following code takes an existing package containing items and their dependencies, and creates a new package containing only the selected items, and removing the dependencies:// Specify the full path and filename of the existing package, // and a location in which to unzip the existing package. Package existingPackage = new Package(@"C:\temp\ExistingPackage.Zip", @"C:\Temp\ExistinPackageUnzipped"); // Unzip the package. existingPackage.Open(); // Create a new package. Package newPackage = Package.Create(@"C:\", "MyNewPackage"); // Scan through the index of the package for explicitly selected items. foreach (IndexItem indexItem in existingPackage.Index) { if (indexItem.Selected) { PackageItem packageItem = existingPackage.GetItem(indexItem.WebDavUrl); newPackage.AddItem(packageItem); } } // Map the items in the source Publication to the destination Publication newPackage.Mappings["/webdav/OriginalPublication"].ImportUrl = "/webdav/DestinationPublication"; // Zip your new package newPackage.SaveAndClose(); existingPackage.SaveAndClose(); - You can also make an import package from scratch, provided that the import package contains items that are valid against one of the following XML schemas, all located in %TRIDION_HOME%\schemas\ :
File Description ImportExportItems.xsd Use this XML schema to validate index.xml, the package index; mappings.xml, the mappings file; and all content items (Components, Pages, Templates and so on) as XML files. ApplicationDataCategories.xsd Use this XML schema to validate application data category configuration files, as stored in the folder %TRIDION_HOME%\config\ImportExport\ApplicationData\ . DependencyTypeGroups.xsd Use this XML schema to validate your XML file containing groups of dependency types, as found in the file %TRIDION_HOME%\config\ImportExport\DependencyTypeGroups.xml . - Once your code has created an import package, you can import it. You can do so using custom code that talks against the Import and Export service, or (if you acquired it) using the SDL Content Porter application.