Export to XML (custom format)

This Action Map exports Perfion data to a custom XML format.

This example is provided as inspiration only. It must be adapted to your Perfion environment to work. Perfion Support does not assist with such adaptations. Please contact your Perfion Partner or your Perfion consultant if you need assistance.

Action Map

  • All lines containing a Command are created as virtuals. This is a recommended best practice

  • The "." in the first and third From field means "current Perfion database"

  • Two datasets (products and brands) are created and mapped separately to begin with

  • The command SELECT.XSLT creates the customized XML data via the related XSLT script

Sample data for building Action Map

NOTE: Line breaks are omitted if you paste scripts from the table below directly to an action. In stead, paste script to Notepad++ and then copy from there. That will preserve line breaks when you paste into an action.

Action Map - From

To

Command

Action

Script

Note

.

PRODUCTS

SELECT.PERFION

 

<Query>
<Select languages='EN'>
<Feature id='**' view='Config' />
</Select>
<From id ='100'/>
<Where>
<Clause id='NoOfCups' operator='>=' value='2' />
</Where>
</Query>

 

table

@FORMAT

 

 

 

 

.

BRANDS

SELECT.PERFION

 

<Query>
<Select languages='EN'>
<Feature id='**' view='Config' />
</Select>
<From id ='BrandName'/>
</Query>

 

table

@FORMAT

 

 

 

 

PRODUCTS

PRODUCTSEXPORT

SELECT

 

 

 

_Value

SKU

 

 

 

 

BrandName

BrandName

 

 

 

 

DiameterCM

Diameter

 

 

 

 

HeightCM

Height

 

 

 

 

ItemName_EN

ProductName

 

 

 

 

RRP

ListPrice

 

 

 

 

WidthCM

Width

 

 

 

 

BRANDS

BRANDSEXPORT

SELECT

 

 

 

_Value

BrandName

 

 

 

 

Country_EN

Country

 

 

 

 

Description_EN

Description

 

 

 

 

.

EXPORT

SELECT.XSLT

 

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform " xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl PerfionActions" xmlns:PerfionActions="urn:actions-library-perfion-com">
<xsl:output method="xml" indent="yes"/>

<!--Create variables to reference the named DataSources in Action Mapping-->
<xsl:variable name="ProductsDS" select="PerfionActions:GetDataSource('PRODUCTSEXPORT')/*"/>
<xsl:variable name="BrandsDS" select="PerfionActions:GetDataSource('BRANDSEXPORT')/*"/>

<!-- *************************************************************************************************************************************
This is where it all begins. Below template matches the default empty <PerfionActionsDataSources/> element.
Since this only matches 1 empty element it will make only 1 iteration. Therefore apply templates on the referenced DataSources instead.-->
<xsl:template match="*">
<Data>
<xsl:apply-templates select="$ProductsDS" mode="ProductsTemplate"/>
<!--<xsl:apply-templates select="$BrandsDS" mode="MfgTemplate"/>-->
</Data>
</xsl:template>

<!--Template to generate a list of all Products, and some select info about them (incl. lookup info from Manufacturers)-->
<xsl:template match="*" mode="ProductsTemplate">
<Product id="{SKU}">
<!--Output some information about the Products-->
<SKU>
<xsl:value-of select="SKU"/>
</SKU>
<Title>
<xsl:value-of select="ProductName"/>
</Title>
<ListPrice>
<xsl:value-of select="ListPrice"/>
</ListPrice>
<Dimensions>
<Height>
<xsl:value-of select="Height"/>
</Height>
<Width>
<xsl:value-of select="Width"/>
</Width>
<Diameter>
<xsl:value-of select="Diameter"/>
</Diameter>
</Dimensions>

<!--Output some information about the Brands (via calling another template to do the detailed work)-->
<BrandInfo>
<xsl:call-template name="BrandBlock">
<xsl:with-param name="currentBrand" select="$BrandsDS[ BrandName = current()/BrandName ]"/>
</xsl:call-template>
</BrandInfo>

</Product>
</xsl:template>

<!--Template to generate contents about a Brand (passed in as parameter)-->
<xsl:template name="BrandBlock">
<xsl:param name="currentBrand" />
<Name>
<xsl:value-of select="$currentBrand/BrandName"/>
</Name>
<Country>
<xsl:value-of select="$currentBrand/Country"/>
</Country>
<Description>
<xsl:value-of select="$currentBrand/Description"/>
</Description>
</xsl:template>

</xsl:stylesheet>

 

EXPORT

C:\Perfion Data\ActionSources\Export\ProductsWithBrand.xml

WRITE.XML