UNPKG

isoxml

Version:

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

84 lines (83 loc) 2.01 kB
import { TAGS } from './constants'; import { registerEntityClass } from '../classRegistry'; import { fromXML, toXML } from '../utils'; const ATTRIBUTES = { A: { name: 'FarmId', type: 'xs:ID', isPrimaryId: true, isOptional: false, isOnlyV4: false, }, B: { name: 'FarmDesignator', type: 'xs:string', isPrimaryId: false, isOptional: false, isOnlyV4: false, }, C: { name: 'FarmStreet', type: 'xs:string', isPrimaryId: false, isOptional: true, isOnlyV4: false, }, D: { name: 'FarmPOBox', type: 'xs:string', isPrimaryId: false, isOptional: true, isOnlyV4: false, }, E: { name: 'FarmPostalCode', type: 'xs:string', isPrimaryId: false, isOptional: true, isOnlyV4: false, }, F: { name: 'FarmCity', type: 'xs:string', isPrimaryId: false, isOptional: true, isOnlyV4: false, }, G: { name: 'FarmState', type: 'xs:string', isPrimaryId: false, isOptional: true, isOnlyV4: false, }, H: { name: 'FarmCountry', type: 'xs:string', isPrimaryId: false, isOptional: true, isOnlyV4: false, }, I: { name: 'CustomerIdRef', type: 'xs:IDREF', isPrimaryId: false, isOptional: true, isOnlyV4: false, }, }; const CHILD_TAGS = {}; export class Farm { constructor(attributes, isoxmlManager) { this.attributes = attributes; this.isoxmlManager = isoxmlManager; this.tag = TAGS.Farm; } static fromXML(xml, isoxmlManager, internalId, targetClass = Farm) { return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId); } toXML() { return toXML(this, ATTRIBUTES, CHILD_TAGS); } } registerEntityClass('main', TAGS.Farm, Farm);