natebeaty / node-onix

Node.JS library to parse/generate ONIX XML files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node-onix

NPM version Build Status

This library can be used to parse, or generate ONIX files from a list of books metadatas. It includes ONIX 2.1 and basic ONIX 3.0 support.

Installation

$ npm install onix

How to use it?

var onix = require("onix");

var xml = onix.create({
    from: {
        company: "GitBook",
        person: "Samy Pesse",
        email: "samy@gitbook.com"
    },
    suplier: {
        name: "ePubDirect",
        availabilityCode: "IP"
    },
    products: [
        {
            // Single record reference which will uniquely identify the product
            record: "gitbook.com-bookId",

            // Notification type
            notification: onix.codes.NOTIFICATION.ADVANCE,

            // ISBN or other id
            id: {
                type: onix.codes.PRODUCTID.ISBN13,
                value: '978123456789'
            },

            //
            title: "My Awesome Book",

            // Language code as ISO 639
            language: "eng",

            // List of prices (number or object) or unique "price"
            prices: [
                {
                    amount: 6,
                    currency: 'eur'
                },

                // Number will default to usd currency
                5
            ]
        }
    ]
});

You can also parse an ONIX feed:

var feed = onix.parse('...');

ONIX 3.0

Add the version number as a string parameter to create and parse:

var xml = onix.create({...}, '3.0');

and

var feed = onix.parse('...', '3.0');

Please note that 3.0 coverage is not complete.

About

Node.JS library to parse/generate ONIX XML files

License:Apache License 2.0


Languages

Language:JavaScript 100.0%