Data transformation example (export)
If, for instance, you want to export properties and the exported xml is not formatted as desired you can transform the xml to another with a different layout.
Example standard export Talk of properties:
<?xml version='1.0' encoding='utf-8'?>
<document>
<header>
<creation-date>2014-03-20T14:37:33</creation-date>
<user>ADMINISTRATORUK</user>
<EE-version state="Production">201311.0.4.0P
</EE-version>
<metadataversion>B_FOEE_2013110000_FB11280
</metadataversion>
<database>MSSQL</database>
<measurementunit>METER</measurementunit>
<ExportDefinitionCode>EXP_PROP</ExportDefinitionCode>
<ExportDocumentCode>exp-prop</ExportDocumentCode>
<SequenceOfDocument>1</SequenceOfDocument>
</header>
<businessobjects>
<Property>
<Address>Columbus Lane</Address>
<City>London</City>
<Country>United Kingdom</Country>
<Name>Columbus Campus</Name>
<IsArchived>False</IsArchived>
</Property>
<Property>
<Address>Columbus Square</Address>
<City>London</City>
<Country>United Kingdom</Country>
<Name>Columbus Square</Name>
<IsArchived>False</IsArchived>
</Property>
<Property>
<Address>Columbus Lane</Address>
<City>London</City>
<Country>United Kingdom</Country>
<Name>Columbus building</Name>
<IsArchived>False</IsArchived>
</Property>
</businessobjects>
</document>
In the final xml the header should be removed as well as the country field and the IsArchived field should contain a different code. Like this:
<?xml version="1.0" encoding="UTF-8"?>
<document xmlns:xs="http://www.w3.org/2001/XMLSchema">
<businessobjects>
<property>
<Name>Columbus Campus</Name>
<Address>Columbus Lane</Address>
<City>London</City>
<IsArchived>0</IsArchived>
</property>
<property>
<Name>Columbus Square</Name>
<Address>Columbus Square</Address>
<City>London</City>
<IsArchived>0</IsArchived>
</property>
<property>
<Name>Columbus building</Name>
<Address>Columbus Lane</Address
><City>London</City>
<IsArchived>0</IsArchived>
</property>
</businessobjects>
</document>
Following xsl file is used to do the transformation:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:template match="/">
<document>
<businessobjects>
<xsl:for-each select="document/
businessobjects/Property">
<property>
<Name>
<xsl:value-of select="Name"/>
</Name>
<Address>
<xsl:value-of select="Address"/>
</Address> <City>
<xsl:value-of select="City"/>
</City>
<xsl:if test="IsArchived='False'">
<IsArchived>0</IsArchived>
</xsl:if>
</property>
</xsl:for-each>
</businessobjects>
</document>
</xsl:template>
</xsl:stylesheet>
Procedure
1. Create an export definition.
2. Create a document for the export definition. In the Data source box, refer to the XML file to export.
3. Create a business object definition for the Properties business object. (see also the example ‘exporting data from multiple business objects’)
4. Create another export document. In the Data source box, refer to the transformed XML file.
5. On the Import-export worker step, on the action menu, click Add to add an XSLT file as a new worker. Add the parameters as specified in the worker specification in section Using standard workers.
6. On the same step remove the PlanonReaderWorker and XMLWriter worker.
7. Run the definition