@sap-ux/xml-odata-annotation-converter
v0.3.2
Published
Converter for OData annotations in XML format.
Downloads
117,510
Readme
@sap-ux/xml-odata-annotation-converter
Installation
Npm
npm install --save @sap-ux/xml-odata-annotation-converter
Yarn
yarn add @sap-ux/xml-odata-annotation-converter
Pnpm
pnpm add @sap-ux/xml-odata-annotation-converter
Usage
Convert XML ast generated by @xml-tools/ast
package to annotation document.
import { readFile } from 'fs/promises';
import { buildAst } from '@xml-tools/ast';
import { parse } from '@xml-tools/parser';
import { convertDocument } from '@sap-ux/xml-odata-annotation-converter';
// read annotation file
const text = await readFile('annotations.xml', 'utf8');
// parse XML
const { cst, tokenVector } = parse(text);
// build AST
const ast = buildAst(cst, tokenVector);
// convert to annotation document format
const annotationDocument = convertDocument(ast);
Convert metadata (data model) defined in an XML file to an array of MetadataElement
.
import { readFile } from 'fs/promises';
import { buildAst } from '@xml-tools/ast';
import { parse } from '@xml-tools/parser';
import { convertMetadataDocument } from '@sap-ux/xml-odata-annotation-converter';
// read annotation file
const text = await readFile('metadata.xml', 'utf8');
// parse XML
const { cst, tokenVector } = parse(text);
// build AST
const ast = buildAst(cst, tokenVector);
// convert to annotation document format
const metadata = convertMetadataDocument(ast);
Keywords
OData annotations