help.axcms.netAxinom Logo
Save Save Chapter Send Feedback

Exporting object lists

AxCMS.net provides you with a feature of exporting object lists into other data formats like XML, CSV etc.

 Exporting in general

Exporting functionality has been made available for you by a left panel control of a CMS overview page. That control is called GeneralExporter.
Currently the following overview pages host that control:

    * Pages Overview
    * Newsletters Overview
    * MailTemplates Overview
    * Documents overview
    * LS Users Overview
    * MS Users Overview
    * Usergroups Overview

Please register following section in your web.config of MS to be able to use default export functionality:

<configSections>
     <section name="ExportDefinitions" type="Axinom.AECMS.ExportDefinitionsSectionHandler, AxCMS.BL" />
</configSections>

 <ExportDefinitions>
    <Xslt AxID="RawXml" Description="Raw XML" />    
  <Xslt Type="Axinom.AECMS.UserManagement.AxUser"
     MimeType="text/plain"
     FileName="admin/ExportDefinitions/UsersToCsv.xslt"
     AxID="AxUsersToCsv"
        SaveDialog="true"
        Extension=".csv"
     Description="CSV" />
    <Xslt Type="Axinom.AECMS.WebControls.AxPage"
        Serializer="Axinom.AECMS.page.PageContentSerializer, AxCMS.BL"     
     AxID="AxPagesContentXML"
     Description="Content XML" />   
  <Xslt Type="Axinom.AECMS.WebControls.AxPage"
     MimeType="text/plain"
        SaveDialog="true"
        Extension=".csv"
        FileName="admin/ExportDefinitions/PagesToCsv.xslt"
     AxID="AxPagesToCsv"
     Description="CSV" />
    <Xslt Type="Axinom.AECMS.page.AxMailTemplate"
        Serializer="Axinom.AECMS.page.PageContentSerializer, AxCMS.BL"
     AxID="AxMailTemplatesContentXML"
     Description="Content XML" />
    <Xslt Type="Axinom.AECMS.page.AxMailTemplate"
     MimeType="text/plain"
     FileName="admin/ExportDefinitions/MailTemplatesToCsv.xslt"
     AxID="AxMailTemplatesToCsv"
        SaveDialog="true"
        Extension=".csv"
     Description="CSV" />
    <Xslt Type="Axinom.AECMS.page.AxNewsletter"
        Serializer="Axinom.AECMS.page.PageContentSerializer, AxCMS.BL"
     AxID="AxNewsletterContentXML"
     Description="Content XML" />   
  <Xslt Type="Axinom.AECMS.page.AxNewsletter"
     MimeType="text/plain"
     FileName="admin/ExportDefinitions/NewslettersToCsv.xslt"
        AxID="AxNewslettersToCsv"
        SaveDialog="true"
        Extension=".csv"
        Description="CSV" />
  <Xslt Type="Axinom.AECMS.document.AxDocument"
     MimeType="text/plain"
     FileName="admin/ExportDefinitions/DocumentsToCsv.xslt"
        AxID="AxDocumentsToCsv"
        SaveDialog="true"
        Extension=".csv"
      Description="CSV" />  
 </ExportDefinitions>

What is exported

During exporting, the objects selected for export are serialized. That means all serializable public properties will be included in resulting XML.

If you don't want a field to be exported, mark it as non-serializable with [XmlIgnore] attribute. Please note however, that this will affect all serializations, including web-services, etc.

Some CMS objects can be extended, so you can add your own serializable properties, e.g. list of categories where object is classified. Please ensure that you have a getter and a setter for your property otherwise .NET does not serialize it.

You can also define your own serializers by implementing interface IExportSerializer and adding your serializer class name to Serializer attribute of xslt element of export definition.

Exporting process

By default, it is possible to export the lists only to XML format. However, you can easily customize the format of export result. In order to do that, you will need an XSLT file for instructing the system about how to produce output suitable for you.

HOWTO: Customizing exporting result

   1. Go to your extras project folder and create an XSLT file there. For example: if you want to export pages in the format of comma-separated-values (CSV) list, please create the following file:
      PagesToCSV.xslt:

      <?xml version="1.0" encoding="UTF-8" ?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes" />
      <xsl:template match="/*"><xsl:text>AxID, Template ID, URL, Name, Publication State, Published, Created
      </xsl:text>
      <xsl:for-each select="*">
      <xsl:value-of select="AxID"/>, <xsl:value-of select="PageTemplateID"/>, <xsl:value-of select="Url"/>, <xsl:value-of select="Name"/>, <xsl:value-of select="PublicationState"/>, <xsl:value-of select="Published"/>, <xsl:value-of select="Created"/><xsl:text>
</xsl:text>
      </xsl:for-each>
      </xsl:template>
      </xsl:stylesheet>

   2. Configure MS Web.config:

      <configSections>
         ...
         <section
                  name="ExportDefinitions"
                  type="Axinom.AECMS.ExportDefinitionsSectionHandler, AxCMS.BL"
         />
      </configSections>
      <ExportDefinitions>
         ...
         <Xslt Type="Axinom.AECMS.WebControls.AxPage"
                 MimeType="text/plain"
                 FileName="extras/ExportDefinitions/PagesToCsv.xslt"
                 AxID="PagesToCsv"
                 SaveDialog="true"                 Extension=".csv"
                 Description="CSV" />
      </ExportDefinitions>

      Explanation:
      * Type - the base type of the list object you are going to apply the XSLT for.
      * MimeType - the MIME type of the output.
      * Extension - the extension of the output file.
      * FileName - the name of the XSLT file relative to the application root path.
      * AxID - the unique identifier of the Xslt-configuration section
      * SaveDialog - whether to display save dialog when exporting or open a new window with export result.
      * Serializer - serializer for the XML. Full class name with optional assembly name should be here.
                         Class should implement IExportSerializer interface.
      * Description - the name of the export type displayed at the GeneralExporter's dropdown list.

   3. Go to the Pages Overview page now and ensure that the Exporter-control's dropdown list has two elements lised: "Raw XML" (the default one) and "CSV". Select "CSV" and press "Export". Provided your XSLT file is written correctly and web.config is configured correctly, you will see a comma-separeted-list of pages' properties in the result window.

HOWTO: Adding the exporter to your custom overview page

GeneralExporter-control can be easily integrated into your custom overview pages too. Please do the following for that:

   1. Open your overview page and add the following there:

      <%@ Register TagPrefix="AxCMS" TagName="GeneralExporter" src="../admin/controls/GeneralExporter.ascx" mce_src="../admin/controls/GeneralExporter.ascx" %>

      <AxMP:Content id="Free" runat="server">      
         <AxCMS:GeneralExporter runat="server" ID="customExportControlInstance" ListObjectType="My.Custom.ObjectType" />
      </AxMP:Content>

   2. Add custom XSLT-files as described in the previous section (if needed) and you are done.

Note that your custom object will need to implement the Axinom.Framework.IKey interface in order for export functionality to work. Without this interface, the information about which objects are selected will not reach the export system.