# @lightweightform/xml

> [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![Travis](https://img.shields.io/travis/alexjoverm/typescript-library-starter.svg)](https://travis-ci.org/alexjoverm/typescript-

Latest version **4.0.0-beta.16** (published 2019-05-15) · Apache2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @lightweightform/xml
pnpm add @lightweightform/xml
yarn add @lightweightform/xml
bun add @lightweightform/xml
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.0.0-beta.16 |
| Published | 2019-05-15 |
| First published | 2018-09-14 |
| Weekly downloads | 0 |
| License | Apache2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=6.0.0 |
| Dependencies | 2 |
| Unpacked size | 436 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Lightweightform |
| Maintainers | lightweightform |

## Links

- npm: https://www.npmjs.com/package/@lightweightform/xml
- Repository: https://bitbucket.org/opensoftgitrepo/lf-xml/src
- npm.io page: https://npm.io/package/@lightweightform/xml

## Dependencies (2)

- [xml-js](https://npm.io/package/xml-js.md) ^1.6.7
- [xml-writer](https://npm.io/package/xml-writer.md) ^1.7.0

## Recent versions

- 4.0.0-beta.16 (latest) — 2019-05-15
- 4.0.0-beta.15 — 2019-05-14
- 4.0.0-beta.14 — 2019-04-24
- 4.0.0-beta.13 — 2019-04-16
- 4.0.0-beta.12 — 2019-03-26
- 4.0.0-beta.10 — 2019-03-21
- 4.0.0-beta.9 — 2019-02-11
- 4.0.0-beta.8 — 2019-02-08
- 4.0.0-beta.7 — 2019-02-08
- 4.0.0-beta.5 — 2019-01-07
- 4.0.0-beta.6 — 2018-12-14
- 4.0.0-beta.4 — 2018-11-27
- 4.0.0-beta.3 — 2018-11-19
- 4.0.0-beta.2 — 2018-11-19
- 4.0.0-beta.1 — 2018-11-19
- … 8 more at https://npm.io/package/@lightweightform/xml/versions

## README

# LF-XML

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Travis](https://img.shields.io/travis/alexjoverm/typescript-library-starter.svg)](https://travis-ci.org/alexjoverm/typescript-library-starter)
[![Coveralls](https://img.shields.io/coveralls/alexjoverm/typescript-library-starter.svg)](https://coveralls.io/github/alexjoverm/typescript-library-starter)

A LF plugin to transform both js value to xml and xml to js value.

### Instalation

```bash
npm install @lightweightform/xml
```

### Usage

```bash
import LfXml from '@lightweightform/xml';
const initialConfiguration: Configuration = {
  xmlVersion: '1.0',
  encoding: 'UTF-8',
  rootName: 'lf-xml',
  lfStorage: ${LF_STORAGE},
  rowSuffix: 'row',
  rowAttribute: 'index',
  formListAttributeSuffix: 'id',
  lfI18n: ${LF_I18N},
  mappings: { xmlName: {'/a/b': B}, jsName: {'/a/B': b} }
};
...
const converter = new LfXml(initialConfiguration);
...
const xml = converter.js2xml(jsValue);
const xmlString = converter.js2xmlString(jsValue);
const js = converter.xml2Js(xmlString);
```

### Methods

| Method       | Description                                                                              | Parameters  | Return Type         |
| ------------ | ---------------------------------------------------------------------------------------- | ----------- | ------------------- |
| js2Xml       | Converts a js object to an equivalent xml representation wrapped by a xml header element | js: any     | XMLElementOrXMLNode |
| js2XmlString | Converts a js object to an equivalent xml string                                         | js: any     | string              |
| xml2Js       | Converts a xml string to js object equivalent with lf schemaComplete representation      | xml: string | js: any             |

### Configuration

- **encoding**: Encoding of the xml object `(default="UTF-8")`
- **xmlVersion**: Version displayed in the xml object `(default="1.0")`
- **rootName**: Root element of the xml object `(default="lf-xml")`
- **headerAttributes**: Map with header attributes added into the root element of the xml object
- **rowSuffix**: Every list elements have a suffix name added into each table's row in the xml object. `(default="row")`
- **rowAttribute**: Every list elements have an additional attribute added into each table's row in the xml object. `(default="index")`
- **formListAttributeSuffix**: Every list elements of type "formList" have an additional attribute added to each formList entry in the xml object `(default="id")`
- **lfStorage**: Storage of the lf application
- **lfI18n**: Lf's i18n service of the lf application
- **mappings**: Map with element's path and name, needs two way mapping to rename element when converting js2xml and xml2js

## Contributing

Contributions are always welcome. Please read our
[contributing guide](./CONTRIBUTING.md) on how to contribute.

## License

LF-XML is released under the [Apache License 2.0](./LICENSE).

---
_Source: https://npm.io/package/@lightweightform/xml · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
