Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@gotamedia/shapeshifter

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gotamedia/shapeshifter

Shapeshifter is a NewsML to NinJS converter. It specifically converts Infomaker NewsML-G2 articles to the Gota Media NinJS extended format.

Source
npmnpm
Version
0.3.0
Version published
Weekly downloads
3
-90%
Maintainers
1
Weekly downloads
 
Created
Source

Shapeshifter

Shapeshifter is a NewsML to NinJS converter. It specifically converts Infomaker NewsML-G2 articles to the Gota Media NinJS extended format.

Installation

npm install --save @gotamedia/shapeshifter

Usage

API

Shapeshifter comes with a very simple API. The idea is to use an article factory to create articles from DOM objects. The articles can then easily be converted into JSON using the JavaScript JSON API.

To create the DOM object you can use any suitable XML engine but the CLI tool uses xmldom.

const { ArticleFactory, AssociationFactory, GeometryFactory } = require("@gotamedia/shapeshifter");
const { DOMParser } = require("xmldom");

const articleDom = new DOMParser().parseFromString(xmlString);
const article = new ArticleFactory(new AssociationFactory(), new GeometryFactory())
    .createArticle(articleDom);

console.log(JSON.stringify(article));

That's it! If you want the object representation of the article you can use the article.toJSON() method to retrieve that.

CLI

Shapeshifter also comes with a convenient CLI tool. You can use it to convert articles in npm scripts or simply on the command line.

The shapeshifter command accepts a single article as stdin input. This makes it easy to use with pipes. Here is a simple example using curl on the command line to fetch and convert an article.

curl --silent --user [credentials] http://xlibris.oc.gota.infomaker.io:8080/opencontent/objects/[uuid] | shapeshifter

And here is an example of converting an article that resides in a file.

shapeshifter < [path/to/article].xml

License

Shapeshifter is released under the MIT License.

license xmldom gotamedia-extended-ninjs

Keywords

newsml

FAQs

Package last updated on 18 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts