Import from XML (eCl@ss data, BMEcat format)

  • Updated

This Action Map imports eCl@ss data from a BMEcat formatted XML-file.

This Action map 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.

  • All lines containing a Command are created as virtuals. This is a recommended best practice
  • The XSLT-script in the first line read data from the XML-file and transforms it to the Perfion table format
  • The empty From-field in the Category mapping sets a default Category for all imported items via the script

Sample XML-file

The XML-file used in the Action Map example (Coffeemachines.xml) is attached at the bottom of the page.

 

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
C:\Perfion Data\ActionSources\BME\Coffeemachines.xml BMEcat SELECT.XSLT.ToTable  

<?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">
  <xsl:output method="xml" indent="yes" />

  <!-- Main template -->
  <xsl:template match="/">
    <Data>
      <xsl:apply-templates select="//PRODUCT" />
    </Data>
  </xsl:template>

  <xsl:template match="PRODUCT" >
    <Product>
      <Id> <xsl:value-of select="SUPPLIER_PID"/> </Id>
      <xsl:apply-templates select="PRODUCT_DETAILS" />
      <xsl:apply-templates select="PRODUCT_FEATURES/FEATURE" />
    </Product>
  </xsl:template>

  <xsl:template match="PRODUCT_DETAILS">
    <xsl:for-each select="*">
      <xsl:element name="{name(.)}">
        <xsl:value-of select="." />
      </xsl:element>
    </xsl:for-each>
  </xsl:template>
 
  <xsl:template match="FEATURE">
    <xsl:variable name="FieldName">
      <xsl:call-template name="removespaces">
        <xsl:with-param name="this" select="FNAME" />
      </xsl:call-template>
    </xsl:variable>

    <xsl:element name="{$FieldName}">
      <xsl:value-of select="FVALUE" />
    </xsl:element>
  </xsl:template>

  <xsl:template name="removespaces">
    <xsl:param name="this" select="." />

    <xsl:value-of select="translate($this, ' ', '')" />
  </xsl:template >

</xsl:stylesheet>

 
BMEcat Importdata SELECT      
Id _Value        
DESCRIPTION_SHORT ItemName_EN        
DESCRIPTION_LONG Description_EN        
EAN EANCode        
PRODUCT_ORDER #Order        
A02-ABC314 WaterTankCapacity        
A02-AUW193 NoOfBeanContainers        
A02-BAI491 CapacityBeanContainer        
A02-BBC191 CableLength        
A02-BAA739 PowerW        
A02-BAA997 WeightKG        
A02-CBC510 WidthCM        
A02-DAB671 LengthCM        
A02-AAC411 HeightCM        
  Category_EN     Value="Coffee & Tea|Coffee Machines";  
Importdata Product IMPORT      

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.