2017 R1

Getting StartedPermanent link for this heading

All you need to get your first export and import running is contained in this chapter. Detailed information about the introduced approaches can be found in the following chapters. As prerequisite you need a Fabasoft Folio installation with Fabasoft app.ducx. More information about Fabasoft app.ducx can be found in the white paper “An Introduction to Fabasoft app.ducx”.

Create a new app.ducx project (in this case TRANS@1.506) with a use case and user interface file. Additionally create two XSLT files (export.xsl and import.xsl) and for the import use case an example XML file (import.xml) is required.

Example

app.ducx Use Case Language

usecases TRANS@1.506
{
  import COOSYSTEM@1.1;
  import FSCVAPP@1.1001;
  import FSCVENV@1.1001;
  import FSCVIEW@1.1001;
  import COOXML@1.1;
  import GENCONT@1.1;

  

  // the export should be invoked with a menu command
  menu usecase Export on selected {
    variant Object {
      impl = expression {
        // cooobj contains the object the user has selected
        // in a testing environment it is fast and easy to use files
        /
/ at the end of this chapter an example for working with
        //
objects instead is provided
        coouser.XSLTransformObject(cooobj, "c:/trans/export.xsl",
          "c:/trans/result.xml");
      }
    }
  }

  // the import should be invoked with a menu command
  menu usecase Import direct {
    variant Object {
     impl = expression {
        coouser.XSLTransformToObject("c:/trans/import.xml", c:/trans/import.xsl");      
      }
    }
  }
}

app.ducx User Interface Language

userinterface TRANS@1.506

{
  import COOSYSTEM@1.1;
  import COOATTREDIT@1.1;
  import COODESK@1.1;
  import COOSEARCH@1.1;
  import FSCVAPP@1.1001;

  

  // the menu commands should be available in the “Tools” menu
  extend menu COODESK@1.1:MenuTools {
    entries = {
      MenuExport,
      MenuImport
    }
  }  
}

export.xsl

<?xml version="1.0" encoding="UTF-8" ?>
<!-- the name of the object is exported -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sys="http://www.fabasoft.com/components/COOSYSTEM@1.1">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"
   omit-xml-declaration="no" />
  <xsl:template match="/">
    <root>
      <objname>
        <xsl:value-of select="*/sys:objname" />
      </objname>
    </root>
  </xsl:template>
</xsl:stylesheet>

import.xsl

<?xml version="1.0" encoding="UTF-8" ?>
<!-- folders are imported and the name and external key are set -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sys="http://www.fabasoft.com/components/COOSYSTEM@1.1"
xmlns:desk="http://www.fabasoft.com/components/COODESK@1.1">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"
    omit-xml-declaration="no" />
  <xsl:template match="/">
    <xsl:apply-templates select="/root/folder" />
  </xsl:template>
  <xsl:template match="folder">
    <sys:Value search="sys:objexternalkey" searchobjclass="desk:Folder"
     create="desk:Folder" match="literal">
      <sys:objname select="name" />
      <sys:objexternalkey select="externalkey" />
    </sys:Value>
  </xsl:template>
</xsl:stylesheet>

import.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- two folders should be imported -->
<root>
  <folder>
    <name>Projects</name>
    <externalkey>projects</externalkey>
  </folder>
  <folder>
    <name>Year 2011</name>
    <externalkey>year2011</externalkey>
  </folder>
</root>

If you compile and run this project two menu commands are available at the end of the “Tools” menu. If you did not provide a multilingual name for the menus they will be called “MenuExport” and “MenuImport”. Put the example files (export.xsl, import.xsl and import.xml) in the defined path on the server running the Fabasoft Folio Web Services. The import command will create two folder objects that can be searched for in Fabasoft Folio. The export command creates an XML file in the defined path.

Working with files is nice for testing but if you do not have access to the file system or you want to set up a productive scenario, here is an extension of the above example:

  • Add an object model file to the app.ducx project and define instances for the XSLT files. Put the two XSLT files (export.xsl and import.xsl) in the resources folder of the app.ducx project.
  • Replace the use case file of the previous example with this one.

Example

app.ducx Object Model Language

objmodel TRANS@1.506
{
  
import COOSYSTEM@1.1;
  import COOXML@1.1;

  
  //
creates a new instance of an XSLT used for export
  instance XSLTransformation ExportXSLTransformation {
    content = file("resources/export.xsl");
  }

  // creates a new instance of an XSLT used for import
  instance XSLTransformation ImportXSLTransformation {
    content = file("resources/import.xsl");
  }  

}

app.ducx Use Case Language

usecases TRANS@1.506
{
  import COOSYSTEM@1.1;
  import FSCVAPP@1.1001;
  import FSCVENV@1.1001;
  import FSCVIEW@1.1001;
  import COOXML@1.1;
  import GENCONT@1.1;

  
  menu usecase Export on selected {
    variant Object {
      impl = expression {
        // will contain the result XML data        
       content @resultxmlcont;

        // the fifth parameter is the out parameter
        
// cooobj contains the object the user has selected
        
// #ExportXSLTransformation is used as XSLT for the transformation
        @resultxmlcont = coouser.XSLTransformObject(cooobj,  
          #ExportXSLTransformation)[5];

        // create a generic content object that will contain the result XML data
        GENCONT@1.1:ContentObject @resultxmlobj =
          #GENCONT@1.1:ContentObject.ObjectCreate()[2];
        @resultxmlobj.content.contcontent = @resultxmlcont;
        @resultxmlobj.content.contextension = "txt";
        @resultxmlobj.objname = "Result XML " + coort.GetCurrentDateTime(cooobj);
      }
    }
  }

  menu usecase Import on selected {
    variant COOSYSTEM@1.1:ContentObject {
     impl = expression {
        // it is assumed that the user selects a content object (cooobj)
        // containingk the
source XML data
        // alternatively, you may provide a dialog for uploading an XML file

        coouser.XSLTransformToObject(cooobj, #ImportXSLTransformation);      
      }
    }
  }
}

By now you should have your first working example. Detailed explanations of the depicted approaches can be found in the following chapters.