Skip to content

Commit

Permalink
Added MARC-in-JSON parser/formatter to README
Browse files Browse the repository at this point in the history
  • Loading branch information
djiao committed Mar 2, 2015
1 parent 2c69add commit 1729e17
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ npm install marc4js

## Features

In the current release (version 0.0.2), marc4js provides the following features
In the current release (version 0.0.4), marc4js provides the following features

* An easy to use API that can handle large record sets.
* Uses Node.js stream API and pipe functions for parsing and writing ISO2709 format, MarcEdit text (mrk) format and MARCXML.
Expand Down Expand Up @@ -74,7 +74,7 @@ fs.createReadStream('/path/to/your/file').pipe(parser).pipe(transformer).pipe(pr

#### Different types of parsers

##### ISO2709Parser
##### Iso2709Parser

Parses ISO2709 format. Used by default or when `fromFormat` is `iso2709` or `marc`

Expand All @@ -98,6 +98,13 @@ Other options:

* `strict`: default is `false`. When in `strict` mode, the parser will fail if the XML is not well-formatted. For details, see the `strict` option in [sax-js](https://github.com/isaacs/sax-js).

##### MijParser

Parses [MARC-in-JSON](http://dilettantes.code4lib.org/blog/2010/09/a-proposal-to-serialize-marc-in-json/) format. Used when `fromFormat` is `json` or `mij`.

The stream and pipe API uses a sax-like JSON stream parser so it doesn't require in-memory storage of the records. Thus it can process
large number of MARC-in-JSON records.

### Transformers

Transformers transform the `marc4js.marc.Record` objects into various MARC formats. Marc4js supports ISO2709, text
Expand Down Expand Up @@ -146,9 +153,9 @@ fs.createReadStream('/path/to/your/file').pipe(parser).pipe(transformer).pipe(pr
`toFormat`: default `iso2709`, possible values `iso2709`, `marc`, `text`, `mrk`, `marcxml`, `xml`
`objectMode`: default `false`. Used to switch between the flowing and paused (aka non-flowing) mode in the [stream API](http://nodejs.org/api/stream.html).

#### Different types of parsers
#### Different types of Transformers

##### ISO2709Transformer
##### Iso2709Transformer

Outputs ISO2709 format. Used by default or when `toFormat` is `iso2709` or `marc`

Expand All @@ -172,6 +179,13 @@ Other options:
* `declaration`: default is `true`. If set to `false`, the XML declaration line (`<?xml versiont ...>`) is not included in the output.
* `root`: default is `true`. If `false`, the root `<collection>` element is not included in the output.

##### MijTransformer

Outputs [MARC-in-JSON](http://dilettantes.code4lib.org/blog/2010/09/a-proposal-to-serialize-marc-in-json/) string. Used when `toFormat` is `json` or `mij`.

Other options:

* asArray: default is `true`. By default the output will be in an JSON array format, even if there is only one record.
If this option set to false, the output will not write the enclosing brackets `[` and `]` at the beginning and end of the output.


0 comments on commit 1729e17

Please sign in to comment.