Copying Data
Copy data from XML files in the package into the C1 CMS System with the data package fragment installer.
The DataPackageFragmentInstaller can copy data from an XML file located in the package ZIP into the C1 CMS System.
If the data you are copying is of a new type created by the Package, you should specify the <mi:Add />
element that create the type before the data is added.
Below is an example that shows data of the IPageTemplate
type being added to the system.
<mi:Add installerType="Composite.Core.PackageSystem.PackageFragmentInstallers.DataPackageFragmentInstaller, Composite" uninstallerType="Composite.Core.PackageSystem.PackageFragmentInstallers.DataPackageFragmentUninstaller, Composite"> <Types> <Type type="Composite.Data.Types.IPageTemplate, Composite" isDynamicAdded="false" > <!-- isDynamicAdded: same as generated type (DataTypeDescriptor) --> <!-- dataFilename path in the zip to a file containing the data (propery name, value)--> <Data dataScopeIdentifier="public" dataFilename="~\Data\IPageTemplates.xml" /> <Data dataScopeIdentifier="administrated" locale="en-US" dataFilename="~\Datas\Composite.Data.Types.IPage.xml" /> </Type> </Types> </mi:Add>
The <Type /> element
The Type
element contains a type name and Data
elements for each scope of data to manipulate.
If the data type being manipulated is a dynamic data type (created using DynamicDataTypePackageFragmentInstaller) you must state this through the isDynamicAdded
property. It’s a requirement the dynamic data types have been defined earlier in install.xml.
The Type
element has the following attributes:
type
: The full name of theIData
type to be manipulated.isDynamicAdded
: When "true", the type is a dynamic data type being created by this package. Used by the validation system to locate type information.allowOverwrite
: When true, existing data with same ID will be overwritten. When false (default) a validation error will be given, if the package try to overwrite data.onlyUpdate
: When true, existing data with same ID is required to already exist and it will be overwritten. Trying to add a new data element will result in a validation error.
The <Data /> element
The Data
element contains information about the data scope to be manipulated and the data file to use. The data file must be located in the package's ZIP file.
dataScopeIdentifier
: The identifier of the data scope data should be added to. Typical values are “public” or “administrated”. If the data type supports the publish work flow, adding “public” data to the “administrated” data scope, will automatically copy it to the “public” data scope as well.dataFilename
: A tilde-based path identifying an XML file located in the package's ZIP file. See below for file format information.locale
:The culture name of the localization scope data should be added to. This only applies for types that are localized. Three kinds of values are possible:- The culture name (“da-DK”, “en-US”, etc).
- “?” - this will make the system add data to the current users active locale.
- “*” - this will make the system add data to all active locales in the system.
Format of the Data XML file
The file referenced by the <Data />
element must have a root element named Data
, and Add elements for each record of data to add.
The fields of the IData
type are directly mapped to properties on the <Add />
elements.
In the following example data is added to a type that has fields named “Id”, “Title” and “PageTemplateFilePath”.
<Data> <Add Id="4D69FE92-6C2D-41e4-BBB4-90F36B0FB3FD" Title="MyPageTemplate1" PageTemplateFilePath="/MyPageTmplate1.xml"/> <Add Id="9659F16F-D846-44fe-8511-913D9BE736E3" Title="MyPageTemplate2" PageTemplateFilePath="/MyPageTmplate2.xml"/> </Data>
Data
” (the root) and “Add
” (all data records).