Skip to content

dobromyslov/commerceml-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

commerceml-parser

Status: Work In Progress

Description

Parser for CommerceML 2.10 standard developed by 1c.ru.

Standard description: https://v8.1c.ru/tekhnologii/obmen-dannymi-i-integratsiya/standarty-i-formaty/standarty-commerceml/commerceml-2/

Features

  • Types description in English
  • SAX XML parser suitable for large files
  • NodeJS
  • TypeScript
  • xojs/xo with plugins for TypeScript - linting
  • ESLint - linting in the WebStorm with ESLint plugin
  • ts-jest - Testing & Coverage

Installation

npm install --save commerceml-parser

or

yarn add commerceml-parser

Note: Interfaces for browsers were extracted into commerceml-parser-core package. Install it with npm install commerceml-parser-core --save-dev or yarn add commerceml-parser-core --dev

Usage

Have a look at usage examples in tests /spec/example.spec.ts.

Run example: npm run example or yarn example

Here is a common usage example:

import {CommerceMlImportParser} from 'commerceml-parser/import-parser';
import {createReadStream} from "fs";

// Create parser for CommerceML catalog import file
const catalogImportParser = new CommerceMlImportParser();

// Define handler for commercial information header
catalogImportParser.onCommercialInformation(commercialInformation => {
  console.log('commercialInformation', JSON.stringify(commercialInformation));
});

// Define handler for classifier XML block
catalogImportParser.onClassifier(classifier => {
  console.log('classifier', JSON.stringify(classifier));
});


// Define handler for classifier group XML blocks
catalogImportParser.onClassifierGroup(classifierGroup => {
  console.log('classifierGroup', JSON.stringify(classifierGroup));
});

// Read CommerceML file and feed it to the parser stream
await catalogImportParser.parse(createReadStream('./data/import0_1_with_nested_groups.xml'));

CommerceML Standard Documentation

v2.10

v2.08

Sample Data

Thanks to

@kirill-zhirnov for his commerceml-js parser written in CoffeeScript.

License

MIT (c) 2020 Viacheslav Dobromyslov <[email protected]>

About

Parser for CommerceML 2.10 standard developed by 1c.ru

Resources

License

Stars

Watchers

Forks

Packages

No packages published