UNPKG

isoxml

Version:

JavaScript library to parse and generate ISOXML (ISO11783-10) files

42 lines (41 loc) 1.12 kB
import { TAGS } from './constants'; import { registerEntityClass } from '../classRegistry'; import { fromXML, toXML } from '../utils'; const ATTRIBUTES = { A: { name: 'ObjectIdRef', type: 'xs:IDREF', isPrimaryId: false, isOptional: false, isOnlyV4: undefined, }, B: { name: 'LinkValue', type: 'xs:token', isPrimaryId: false, isOptional: false, isOnlyV4: undefined, }, C: { name: 'LinkDesignator', type: 'xs:string', isPrimaryId: false, isOptional: true, isOnlyV4: undefined, }, }; const CHILD_TAGS = {}; export class Link { constructor(attributes, isoxmlManager) { this.attributes = attributes; this.isoxmlManager = isoxmlManager; this.tag = TAGS.Link; } static fromXML(xml, isoxmlManager, internalId, targetClass = Link) { return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId); } toXML() { return toXML(this, ATTRIBUTES, CHILD_TAGS); } } registerEntityClass('main', TAGS.Link, Link);