diff --git a/src/BaseTypes/INamespaced.ts b/src/BaseTypes/INamespaced.ts new file mode 100644 index 0000000000000000000000000000000000000000..86fff834e3309ad017a871923c0cd632e243162a --- /dev/null +++ b/src/BaseTypes/INamespaced.ts @@ -0,0 +1,3 @@ +export interface INamespaced { + get namespace(): string; +} diff --git a/src/BaseTypes/ISchemaInformation.ts b/src/BaseTypes/ISchemaInformation.ts new file mode 100644 index 0000000000000000000000000000000000000000..d29d13fce813d351cb97fff668701507548d07ac --- /dev/null +++ b/src/BaseTypes/ISchemaInformation.ts @@ -0,0 +1,6 @@ +export interface ISchemaInformation { + schemaVersion: string; + namespaceUrl: string; + namespace: string; + schemaLocation: string; +} diff --git a/src/BaseTypes/XMLBoolean.ts b/src/BaseTypes/XMLBoolean.ts index 7a4b67c5ac215fb83b9667b6e4c42dc59c8a2d7c..2a73499882a1d8abec87870ba823477ca6a8a398 100644 --- a/src/BaseTypes/XMLBoolean.ts +++ b/src/BaseTypes/XMLBoolean.ts @@ -1,8 +1,8 @@ import { XMLElement } from "./XMLElement"; export class XMLBoolean extends XMLElement { - constructor(options: XMLBoolean) { - super(options); + constructor(element?: Partial<XMLBoolean>) { + super(element); } get value() { diff --git a/src/BaseTypes/XMLDate.ts b/src/BaseTypes/XMLDate.ts index d219730f1e878cccca4699e4b7214cfac317d46a..64e304795e7442c6bf40cc70e06fac7d40145d9c 100644 --- a/src/BaseTypes/XMLDate.ts +++ b/src/BaseTypes/XMLDate.ts @@ -1,8 +1,8 @@ import { XMLElement } from "./XMLElement"; export class XMLDate extends XMLElement { - constructor(options?: XMLDate) { - super(options); + constructor(element?: Partial<XMLDate>) { + super(element); } get value() { diff --git a/src/BaseTypes/XMLElement.ts b/src/BaseTypes/XMLElement.ts index 0490a6b1a7eb373ee88753cca2561b4bcd6f59bd..ed0943357266da8b8b517089499b091ddf4db4c4 100644 --- a/src/BaseTypes/XMLElement.ts +++ b/src/BaseTypes/XMLElement.ts @@ -13,7 +13,7 @@ export class XMLElement { _text?: string; _attr?: AttributeType; - constructor(element?: XMLElement) { + constructor(element?: Partial<XMLElement>) { this._text = (element && element._text) || ""; this._attr = (element && element._attr) || {}; } diff --git a/src/BaseTypes/XMLList.ts b/src/BaseTypes/XMLList.ts index a7ddeb38272e368acc37b9f43c1b6434b84f299c..a0385ef2997f23f5414dee99d3ab12da2dfb31d6 100644 --- a/src/BaseTypes/XMLList.ts +++ b/src/BaseTypes/XMLList.ts @@ -1,8 +1,8 @@ import { XMLElement } from "./XMLElement"; export class XMLList extends XMLElement { - constructor(options?: XMLList) { - super(options); + constructor(element?: Partial<XMLList>) { + super(element); } get values() { diff --git a/src/BaseTypes/XMLNumber.ts b/src/BaseTypes/XMLNumber.ts index 0da573c771515b23e1f93fdd48ded9239c919019..f5264828bbc24b299888edcd154e23067beb2af0 100644 --- a/src/BaseTypes/XMLNumber.ts +++ b/src/BaseTypes/XMLNumber.ts @@ -1,8 +1,8 @@ import { XMLElement } from "./XMLElement"; export class XMLNumber extends XMLElement { - constructor(options?: XMLNumber) { - super(options); + constructor(element?: Partial<XMLNumber>) { + super(element); } get value() { diff --git a/src/BaseTypes/index.ts b/src/BaseTypes/index.ts index 26c35460891683d36ef7428e0dcbfa3823508c6f..19618ca3a061b91f303f82040e5b4542864bfa9c 100644 --- a/src/BaseTypes/index.ts +++ b/src/BaseTypes/index.ts @@ -3,3 +3,5 @@ export * from "./XMLDate"; export * from "./XMLElement"; export * from "./XMLList"; export * from "./XMLNumber"; +export * from "./INamespaced"; +export * from "./ISchemaInformation"; diff --git a/src/DCC.ts b/src/DCC.ts index c975e9959a11f2d4e17a72254748028facc963e7..1a0e9f4c3cd0688af077084a5ba93773f59013dc 100644 --- a/src/DCC.ts +++ b/src/DCC.ts @@ -1,60 +1,67 @@ -import * as si from "./SI"; -import { XMLDate as BaseXMLDate, XMLElement as BaseXMLElement, XMLNumber as BaseXMLNumber, XMLBoolean as BaseXMLBoolean, XMLList as BaseXMLList } from "./BaseTypes"; +import * as si from "./DSI"; +import { XMLDate, XMLElement, XMLNumber, XMLBoolean, XMLList, INamespaced, ISchemaInformation } from "./BaseTypes"; import { ensureArray } from "./Util"; -export const schemaVersion = "3.1.0"; -export const namespace = `https://ptb.de/dcc`; -export const schemaLocation = `${namespace}/v${schemaVersion}/dcc.xsd`; - -export class XMLElement extends BaseXMLElement { - getNamespace() { - return "dcc"; +const schemaVersion = "3.1.0"; +const namespace = "dcc"; +const namespaceUrl = `https://ptb.de/${namespace}`; +const schemaLocation = `${namespaceUrl}/v${schemaVersion}/dcc.xsd`; +export const DCC: ISchemaInformation = { + schemaVersion, + namespace, + namespaceUrl, + schemaLocation, +}; + +export class DCCXMLElement extends XMLElement implements INamespaced { + get namespace() { + return DCC.namespace; } } -export class XMLBoolean extends BaseXMLBoolean { - getNamespace() { - return "dcc"; +export class DCCXMLBoolean extends XMLBoolean implements INamespaced { + get namespace() { + return DCC.namespace; } } -export class XMLNumber extends BaseXMLNumber { - getNamespace() { - return "dcc"; +export class DCCXMLNumber extends XMLNumber implements INamespaced { + get namespace() { + return DCC.namespace; } } -export class XMLDate extends BaseXMLDate { - getNamespace() { - return "dcc"; +export class DCCXMLDate extends XMLDate implements INamespaced { + get namespace() { + return DCC.namespace; } } -export class XMLList extends BaseXMLList { - getNamespace() { - return "dcc"; +export class DCCXMLList extends XMLList implements INamespaced { + get namespace() { + return DCC.namespace; } } /** The root element that contains the four rings of the DCC. */ -export class DigitalCalibrationCertificateType extends XMLElement { +export class DigitalCalibrationCertificateType extends DCCXMLElement { administrativeData: AdministrativeDataType; measurementResults: MeasurementResultListType; - comment?: XMLElement; + comment?: DCCXMLElement; document?: ByteDataType; constructor(el: Partial<DigitalCalibrationCertificateType> = {}) { super(el); this.administrativeData = new AdministrativeDataType(el.administrativeData); this.measurementResults = new MeasurementResultListType(el.measurementResults); - if (el.comment) this.comment = new XMLElement(el.comment); + if (el.comment) this.comment = new DCCXMLElement(el.comment); if (el.document) this.document = new ByteDataType(el.document); } } /** The element administrativeData contains all essential administrative information about the calibration. * The entries in this area are basically the same and regulated in all DCCs. */ -export class AdministrativeDataType extends XMLElement { +export class AdministrativeDataType extends DCCXMLElement { dccSoftware: SoftwareListType; coreData: CoreDataType; items: ItemListType; @@ -76,7 +83,7 @@ export class AdministrativeDataType extends XMLElement { } /** List of measurement results that are part of a DCC. */ -export class MeasurementResultListType extends XMLElement { +export class MeasurementResultListType extends DCCXMLElement { measurementResult: MeasurementResultType[]; constructor(el: Partial<MeasurementResultListType> = {}) { @@ -87,25 +94,25 @@ export class MeasurementResultListType extends XMLElement { /** The byteDataType defines a type which allows to add binary encoded files to the measurement result * section. */ -export class ByteDataType extends XMLElement { +export class ByteDataType extends DCCXMLElement { name?: TextType; description?: RichContentType; - fileName: XMLElement; - mimeType: XMLElement; - dataBase64: XMLElement; + fileName: DCCXMLElement; + mimeType: DCCXMLElement; + dataBase64: DCCXMLElement; constructor(el: Partial<ByteDataType> = {}) { super(el); if (el.name) this.name = new TextType(el.name); if (el.description) this.description = new RichContentType(el.description); - this.fileName = new XMLElement(el.fileName); - this.mimeType = new XMLElement(el.mimeType); - this.dataBase64 = new XMLElement(el.dataBase64); + this.fileName = new DCCXMLElement(el.fileName); + this.mimeType = new DCCXMLElement(el.mimeType); + this.dataBase64 = new DCCXMLElement(el.dataBase64); } } /** A list of software elements. */ -export class SoftwareListType extends XMLElement { +export class SoftwareListType extends DCCXMLElement { software: SoftwareType[]; constructor(el: Partial<SoftwareListType> = {}) { @@ -115,36 +122,36 @@ export class SoftwareListType extends XMLElement { } /** Important metadata for the DCC containing the global unique identifier and other identifications. */ -export class CoreDataType extends XMLElement { - countryCodeISO3166_1: XMLElement; - usedLangCodeISO639_1: XMLElement[]; - mandatoryLangCodeISO639_1: XMLElement[]; - uniqueIdentifier: XMLElement; +export class CoreDataType extends DCCXMLElement { + countryCodeISO3166_1: DCCXMLElement; + usedLangCodeISO639_1: DCCXMLElement[]; + mandatoryLangCodeISO639_1: DCCXMLElement[]; + uniqueIdentifier: DCCXMLElement; identifications?: IdentificationListType; - receiptDate?: XMLDate; - beginPerformanceDate: XMLDate; - endPerformanceDate: XMLDate; - performanceLocation: XMLElement; + receiptDate?: DCCXMLDate; + beginPerformanceDate: DCCXMLDate; + endPerformanceDate: DCCXMLDate; + performanceLocation: DCCXMLElement; previousReport?: HashType; constructor(el: Partial<CoreDataType> = {}) { super(el); - this.countryCodeISO3166_1 = new XMLElement(el.countryCodeISO3166_1); - this.usedLangCodeISO639_1 = ensureArray(el.usedLangCodeISO639_1).map((x) => new XMLElement(x)); - this.mandatoryLangCodeISO639_1 = ensureArray(el.mandatoryLangCodeISO639_1).map((x) => new XMLElement(x)); - this.uniqueIdentifier = new XMLElement(el.uniqueIdentifier); + this.countryCodeISO3166_1 = new DCCXMLElement(el.countryCodeISO3166_1); + this.usedLangCodeISO639_1 = ensureArray(el.usedLangCodeISO639_1).map((x) => new DCCXMLElement(x)); + this.mandatoryLangCodeISO639_1 = ensureArray(el.mandatoryLangCodeISO639_1).map((x) => new DCCXMLElement(x)); + this.uniqueIdentifier = new DCCXMLElement(el.uniqueIdentifier); if (el.identifications) this.identifications = new IdentificationListType(el.identifications); - if (el.receiptDate) this.receiptDate = new XMLDate(el.receiptDate); - this.beginPerformanceDate = new XMLDate(el.beginPerformanceDate); - this.endPerformanceDate = new XMLDate(el.endPerformanceDate); - this.performanceLocation = new XMLElement(el.performanceLocation); + if (el.receiptDate) this.receiptDate = new DCCXMLDate(el.receiptDate); + this.beginPerformanceDate = new DCCXMLDate(el.beginPerformanceDate); + this.endPerformanceDate = new DCCXMLDate(el.endPerformanceDate); + this.performanceLocation = new DCCXMLElement(el.performanceLocation); if (el.previousReport) this.previousReport = new HashType(el.previousReport); } } /** This element is a set of calibrated items. * Contains one or more item elements. */ -export class ItemListType extends XMLElement { +export class ItemListType extends DCCXMLElement { name?: TextType; equipmentClass?: EquipmentClassType; description?: RichContentType; @@ -164,19 +171,19 @@ export class ItemListType extends XMLElement { } /** Information about the calibration laboratory. */ -export class CalibrationLaboratoryType extends XMLElement { - calibrationLaboratoryCode?: XMLElement; +export class CalibrationLaboratoryType extends DCCXMLElement { + calibrationLaboratoryCode?: DCCXMLElement; contact: ContactType; constructor(el: Partial<CalibrationLaboratoryType> = {}) { super(el); - if (el.calibrationLaboratoryCode) this.calibrationLaboratoryCode = new XMLElement(el.calibrationLaboratoryCode); + if (el.calibrationLaboratoryCode) this.calibrationLaboratoryCode = new DCCXMLElement(el.calibrationLaboratoryCode); this.contact = new ContactType(el.contact); } } /** List of responsible persons for a DCC. */ -export class RespPersonListType extends XMLElement { +export class RespPersonListType extends DCCXMLElement { respPerson: RespPersonType[]; constructor(el: Partial<RespPersonListType> = {}) { @@ -185,27 +192,27 @@ export class RespPersonListType extends XMLElement { } } -export class ContactType extends XMLElement { +export class ContactType extends DCCXMLElement { name: TextType; - eMail: XMLElement; - phone?: XMLElement; - fax?: XMLElement; + eMail: DCCXMLElement; + phone?: DCCXMLElement; + fax?: DCCXMLElement; location: LocationType; descriptionData?: ByteDataType; constructor(el: Partial<ContactType> = {}) { super(el); this.name = new TextType(el.name); - this.eMail = new XMLElement(el.eMail); - if (el.phone) this.phone = new XMLElement(el.phone); - if (el.fax) this.fax = new XMLElement(el.fax); + this.eMail = new DCCXMLElement(el.eMail); + if (el.phone) this.phone = new DCCXMLElement(el.phone); + if (el.fax) this.fax = new DCCXMLElement(el.fax); this.location = new LocationType(el.location); if (el.descriptionData) this.descriptionData = new ByteDataType(el.descriptionData); } } /** List of statements attached to a DCC. */ -export class StatementListType extends XMLElement { +export class StatementListType extends DCCXMLElement { statement: StatementMetaDataType[]; constructor(el: Partial<StatementListType> = {}) { @@ -215,23 +222,23 @@ export class StatementListType extends XMLElement { } /** Information about a software including its name, version and a description. */ -export class SoftwareType extends XMLElement { +export class SoftwareType extends DCCXMLElement { name: TextType; - release: XMLElement; - type?: XMLElement; + release: DCCXMLElement; + type?: DCCXMLElement; description?: RichContentType; constructor(el: Partial<SoftwareType> = {}) { super(el); this.name = new TextType(el.name); - this.release = new XMLElement(el.release); - if (el.type) this.type = new XMLElement(el.type); + this.release = new DCCXMLElement(el.release); + if (el.type) this.type = new DCCXMLElement(el.type); if (el.description) this.description = new RichContentType(el.description); } } /** Allow multiple refTypes for one element as attribute. */ -export class RefTypesType extends XMLElement { +export class RefTypesType extends DCCXMLElement { constructor(el: Partial<RefTypesType> = {}) { super(el); } @@ -240,7 +247,7 @@ export class RefTypesType extends XMLElement { /** The textType defines the type for writing localized text in the DCC. * In this Type, the element content can be used many times with different language definition (attribute * lang). */ -export class TextType extends XMLElement { +export class TextType extends DCCXMLElement { content: StringWithLangType[]; constructor(el: Partial<TextType> = {}) { @@ -276,7 +283,7 @@ export class TextType extends XMLElement { } /** Rich content Type can contain files and formulas beside the normal text content. */ -export class RichContentType extends XMLElement { +export class RichContentType extends DCCXMLElement { name?: TextType; content?: StringWithLangType[]; file?: ByteDataType[]; @@ -292,7 +299,7 @@ export class RichContentType extends XMLElement { } /** List of measuring equipment and instruments */ -export class MeasuringEquipmentListType extends XMLElement { +export class MeasuringEquipmentListType extends DCCXMLElement { name?: TextType; equipmentClass?: EquipmentClassType; description?: RichContentType; @@ -312,19 +319,19 @@ export class MeasuringEquipmentListType extends XMLElement { } /** Clear name(s) of the item(s) and identifier(s). */ -export class EquipmentClassType extends XMLElement { - reference: XMLElement; - classID: XMLElement; +export class EquipmentClassType extends DCCXMLElement { + reference: DCCXMLElement; + classID: DCCXMLElement; constructor(el: Partial<EquipmentClassType> = {}) { super(el); - this.reference = new XMLElement(el.reference); - this.classID = new XMLElement(el.classID); + this.reference = new DCCXMLElement(el.reference); + this.classID = new DCCXMLElement(el.classID); } } /** List of additional identifications. */ -export class IdentificationListType extends XMLElement { +export class IdentificationListType extends DCCXMLElement { identification: IdentificationType[]; constructor(el: Partial<IdentificationListType> = {}) { @@ -334,13 +341,13 @@ export class IdentificationListType extends XMLElement { } /** Information about a measuring equipment or instrument used in the calibration */ -export class MeasuringEquipmentType extends XMLElement { +export class MeasuringEquipmentType extends DCCXMLElement { name: TextType; equipmentClass?: EquipmentClassType; description?: RichContentType; certificate?: HashType; manufacturer?: ContactNotStrictType; - model?: XMLElement; + model?: DCCXMLElement; identifications?: IdentificationListType; measuringEquipmentQuantities?: MeasuringEquipmentQuantityListType; @@ -351,50 +358,50 @@ export class MeasuringEquipmentType extends XMLElement { if (el.description) this.description = new RichContentType(el.description); if (el.certificate) this.certificate = new HashType(el.certificate); if (el.manufacturer) this.manufacturer = new ContactNotStrictType(el.manufacturer); - if (el.model) this.model = new XMLElement(el.model); + if (el.model) this.model = new DCCXMLElement(el.model); if (el.identifications) this.identifications = new IdentificationListType(el.identifications); if (el.measuringEquipmentQuantities) this.measuringEquipmentQuantities = new MeasuringEquipmentQuantityListType(el.measuringEquipmentQuantities); } } -export class HashType extends XMLElement { +export class HashType extends DCCXMLElement { referral: TextType; - referralID: XMLElement; - procedure: XMLElement; - value: XMLElement; + referralID: DCCXMLElement; + procedure: DCCXMLElement; + value: DCCXMLElement; linkedReport?: HashType; constructor(el: Partial<HashType> = {}) { super(el); this.referral = new TextType(el.referral); - this.referralID = new XMLElement(el.referralID); - this.procedure = new XMLElement(el.procedure); - this.value = new XMLElement(el.value); + this.referralID = new DCCXMLElement(el.referralID); + this.procedure = new DCCXMLElement(el.procedure); + this.value = new DCCXMLElement(el.value); if (el.linkedReport) this.linkedReport = new HashType(el.linkedReport); } } -export class ContactNotStrictType extends XMLElement { +export class ContactNotStrictType extends DCCXMLElement { name: TextType; - eMail?: XMLElement; - phone?: XMLElement; - fax?: XMLElement; + eMail?: DCCXMLElement; + phone?: DCCXMLElement; + fax?: DCCXMLElement; location?: LocationType; descriptionData?: ByteDataType; constructor(el: Partial<ContactNotStrictType> = {}) { super(el); this.name = new TextType(el.name); - if (el.eMail) this.eMail = new XMLElement(el.eMail); - if (el.phone) this.phone = new XMLElement(el.phone); - if (el.fax) this.fax = new XMLElement(el.fax); + if (el.eMail) this.eMail = new DCCXMLElement(el.eMail); + if (el.phone) this.phone = new DCCXMLElement(el.phone); + if (el.fax) this.fax = new DCCXMLElement(el.fax); if (el.location) this.location = new LocationType(el.location); if (el.descriptionData) this.descriptionData = new ByteDataType(el.descriptionData); } } /** List of values which describes the measurement equipment. */ -export class MeasuringEquipmentQuantityListType extends XMLElement { +export class MeasuringEquipmentQuantityListType extends DCCXMLElement { measuringEquipmentQuantity: MeasuringEquipmentQuantityType[]; constructor(el: Partial<MeasuringEquipmentQuantityListType> = {}) { @@ -404,7 +411,7 @@ export class MeasuringEquipmentQuantityListType extends XMLElement { } /** Value which describes the measuringEquipment */ -export class MeasuringEquipmentQuantityType extends XMLElement { +export class MeasuringEquipmentQuantityType extends DCCXMLElement { name?: TextType; description?: RichContentType; @@ -561,13 +568,13 @@ export class MeasuringEquipmentQuantityType extends XMLElement { } /** A item that is calibrated in this DCC. */ -export class ItemType extends XMLElement { +export class ItemType extends DCCXMLElement { name: TextType; equipmentClass?: EquipmentClassType; description?: RichContentType; installedSoftwares?: SoftwareListType; manufacturer: ContactNotStrictType; - model?: XMLElement; + model?: DCCXMLElement; identifications: IdentificationListType; constructor(el: Partial<ItemType> = {}) { @@ -577,94 +584,94 @@ export class ItemType extends XMLElement { if (el.description) this.description = new RichContentType(el.description); if (el.installedSoftwares) this.installedSoftwares = new SoftwareListType(el.installedSoftwares); this.manufacturer = new ContactNotStrictType(el.manufacturer); - if (el.model) this.model = new XMLElement(el.model); + if (el.model) this.model = new DCCXMLElement(el.model); this.identifications = new IdentificationListType(el.identifications); } } /** An additional identification (eg. reference no., serial number, etc.). */ -export class IdentificationType extends XMLElement { - issuer: XMLElement; - value: XMLElement; +export class IdentificationType extends DCCXMLElement { + issuer: DCCXMLElement; + value: DCCXMLElement; name?: TextType; constructor(el: Partial<IdentificationType> = {}) { super(el); - this.issuer = new XMLElement(el.issuer); - this.value = new XMLElement(el.value); + this.issuer = new DCCXMLElement(el.issuer); + this.value = new DCCXMLElement(el.value); if (el.name) this.name = new TextType(el.name); } } /** A person responsible for a DCC. */ -export class RespPersonType extends XMLElement { +export class RespPersonType extends DCCXMLElement { person: ContactNotStrictType; description?: RichContentType; - role?: XMLElement; - mainSigner?: XMLBoolean; - cryptElectronicSeal?: XMLBoolean; - cryptElectronicSignature?: XMLBoolean; - cryptElectronicTimeStamp?: XMLBoolean; + role?: DCCXMLElement; + mainSigner?: DCCXMLBoolean; + cryptElectronicSeal?: DCCXMLBoolean; + cryptElectronicSignature?: DCCXMLBoolean; + cryptElectronicTimeStamp?: DCCXMLBoolean; constructor(el: Partial<RespPersonType> = {}) { super(el); this.person = new ContactNotStrictType(el.person); if (el.description) this.description = new RichContentType(el.description); - if (el.role) this.role = new XMLElement(el.role); - if (el.mainSigner) this.mainSigner = new XMLBoolean(el.mainSigner); - if (el.cryptElectronicSeal) this.cryptElectronicSeal = new XMLBoolean(el.cryptElectronicSeal); - if (el.cryptElectronicSignature) this.cryptElectronicSignature = new XMLBoolean(el.cryptElectronicSignature); - if (el.cryptElectronicTimeStamp) this.cryptElectronicTimeStamp = new XMLBoolean(el.cryptElectronicTimeStamp); + if (el.role) this.role = new DCCXMLElement(el.role); + if (el.mainSigner) this.mainSigner = new DCCXMLBoolean(el.mainSigner); + if (el.cryptElectronicSeal) this.cryptElectronicSeal = new DCCXMLBoolean(el.cryptElectronicSeal); + if (el.cryptElectronicSignature) this.cryptElectronicSignature = new DCCXMLBoolean(el.cryptElectronicSignature); + if (el.cryptElectronicTimeStamp) this.cryptElectronicTimeStamp = new DCCXMLBoolean(el.cryptElectronicTimeStamp); } } -export class StatementMetaDataType extends XMLElement { - countryCodeISO3166_1?: XMLElement[]; - convention?: XMLElement; - traceable?: XMLBoolean; - norm?: XMLElement[]; - reference?: XMLElement[]; +export class StatementMetaDataType extends DCCXMLElement { + countryCodeISO3166_1?: DCCXMLElement[]; + convention?: DCCXMLElement; + traceable?: DCCXMLBoolean; + norm?: DCCXMLElement[]; + reference?: DCCXMLElement[]; declaration?: RichContentType; - valid?: XMLBoolean; - date?: XMLDate; - period?: XMLElement; + valid?: DCCXMLBoolean; + date?: DCCXMLDate; + period?: DCCXMLElement; respAuthority?: ContactType; // region choice - conformity?: XMLElement; - conformityXMLList?: XMLList; + conformity?: DCCXMLElement; + conformityXMLList?: DCCXMLList; // endregion choice data?: DataType; - nonSIDefinition?: XMLElement; - nonSIUnit?: XMLElement; + nonSIDefinition?: DCCXMLElement; + nonSIUnit?: DCCXMLElement; constructor(el: Partial<StatementMetaDataType> = {}) { super(el); - if (el.countryCodeISO3166_1) this.countryCodeISO3166_1 = ensureArray(el.countryCodeISO3166_1).map((x) => new XMLElement(x)); - if (el.convention) this.convention = new XMLElement(el.convention); - if (el.traceable) this.traceable = new XMLBoolean(el.traceable); - if (el.norm) this.norm = ensureArray(el.norm).map((x) => new XMLElement(x)); - if (el.reference) this.reference = ensureArray(el.reference).map((x) => new XMLElement(x)); + if (el.countryCodeISO3166_1) this.countryCodeISO3166_1 = ensureArray(el.countryCodeISO3166_1).map((x) => new DCCXMLElement(x)); + if (el.convention) this.convention = new DCCXMLElement(el.convention); + if (el.traceable) this.traceable = new DCCXMLBoolean(el.traceable); + if (el.norm) this.norm = ensureArray(el.norm).map((x) => new DCCXMLElement(x)); + if (el.reference) this.reference = ensureArray(el.reference).map((x) => new DCCXMLElement(x)); if (el.declaration) this.declaration = new RichContentType(el.declaration); - if (el.valid) this.valid = new XMLBoolean(el.valid); - if (el.date) this.date = new XMLDate(el.date); - if (el.period) this.period = new XMLElement(el.period); + if (el.valid) this.valid = new DCCXMLBoolean(el.valid); + if (el.date) this.date = new DCCXMLDate(el.date); + if (el.period) this.period = new DCCXMLElement(el.period); if (el.respAuthority) this.respAuthority = new ContactType(el.respAuthority); // choice - if (el.conformity) this.conformity = new XMLElement(el.conformity); - else if (el.conformityXMLList) this.conformityXMLList = new XMLList(el.conformityXMLList); + if (el.conformity) this.conformity = new DCCXMLElement(el.conformity); + else if (el.conformityXMLList) this.conformityXMLList = new DCCXMLList(el.conformityXMLList); if (el.data) this.data = new DataType(el.data); - if (el.nonSIDefinition) this.nonSIDefinition = new XMLElement(el.nonSIDefinition); - if (el.nonSIUnit) this.nonSIUnit = new XMLElement(el.nonSIUnit); + if (el.nonSIDefinition) this.nonSIDefinition = new DCCXMLElement(el.nonSIDefinition); + if (el.nonSIUnit) this.nonSIUnit = new DCCXMLElement(el.nonSIUnit); } } /** A measurement results with the methods, software and equipments used for the calibration. * Also contains influence conditions and a list of the actual results. */ -export class MeasurementResultType extends XMLElement { +export class MeasurementResultType extends DCCXMLElement { name: TextType; description?: RichContentType; usedMethods?: UsedMethodListType; @@ -688,7 +695,7 @@ export class MeasurementResultType extends XMLElement { } /** List of the methods used in the calibration. */ -export class UsedMethodListType extends XMLElement { +export class UsedMethodListType extends DCCXMLElement { usedMethod: UsedMethodType[]; constructor(el: Partial<UsedMethodListType> = {}) { @@ -698,7 +705,7 @@ export class UsedMethodListType extends XMLElement { } /** List of conditions that influence the measurements. */ -export class InfluenceConditionListType extends XMLElement { +export class InfluenceConditionListType extends DCCXMLElement { influenceCondition: ConditionType[]; constructor(el: Partial<InfluenceConditionListType> = {}) { @@ -708,7 +715,7 @@ export class InfluenceConditionListType extends XMLElement { } /** List of results of the calibration. */ -export class ResultListType extends XMLElement { +export class ResultListType extends DCCXMLElement { result: ResultType[]; constructor(el: Partial<ResultListType> = {}) { @@ -718,7 +725,7 @@ export class ResultListType extends XMLElement { } /** A list of additional metadata elements. */ -export class MeasurementMetaDataListType extends XMLElement { +export class MeasurementMetaDataListType extends DCCXMLElement { metaData: StatementMetaDataType[]; constructor(el: Partial<MeasurementMetaDataListType> = {}) { @@ -728,27 +735,27 @@ export class MeasurementMetaDataListType extends XMLElement { } /** A method used in the calibration. */ -export class UsedMethodType extends XMLElement { +export class UsedMethodType extends DCCXMLElement { name: TextType; description?: RichContentType; - norm?: XMLElement[]; - reference?: XMLElement[]; + norm?: DCCXMLElement[]; + reference?: DCCXMLElement[]; constructor(el: Partial<UsedMethodType> = {}) { super(el); this.name = new TextType(el.name); if (el.description) this.description = new RichContentType(el.description); - if (el.norm) this.norm = ensureArray(el.norm).map((x) => new XMLElement(x)); - if (el.reference) this.reference = ensureArray(el.reference).map((x) => new XMLElement(x)); + if (el.norm) this.norm = ensureArray(el.norm).map((x) => new DCCXMLElement(x)); + if (el.reference) this.reference = ensureArray(el.reference).map((x) => new DCCXMLElement(x)); } } /** Condition (e.g. environmental) under which the calibrations were performed which have an influence on * the measurement results. */ -export class ConditionType extends XMLElement { +export class ConditionType extends DCCXMLElement { name: TextType; description?: RichContentType; - status?: XMLElement; + status?: DCCXMLElement; certificate?: HashType; data: DataType; @@ -756,13 +763,13 @@ export class ConditionType extends XMLElement { super(el); this.name = new TextType(el.name); if (el.description) this.description = new RichContentType(el.description); - if (el.status) this.status = new XMLElement(el.status); + if (el.status) this.status = new DCCXMLElement(el.status); if (el.certificate) this.certificate = new HashType(el.certificate); this.data = new DataType(el.data); } } -export class DataType extends XMLElement { +export class DataType extends DCCXMLElement { // region choice text?: RichContentType[]; formula?: FormulaType[]; @@ -787,7 +794,7 @@ export class DataType extends XMLElement { } /** The actual result of the calibration. */ -export class ResultType extends XMLElement { +export class ResultType extends DCCXMLElement { name: TextType; description?: RichContentType; data: DataType; @@ -801,9 +808,9 @@ export class ResultType extends XMLElement { } /** This data block is used to add formulas and equations to the measurement result section of the DCC. */ -export class FormulaType extends XMLElement { +export class FormulaType extends DCCXMLElement { // region choice - latex?: XMLElement; + latex?: DCCXMLElement; mathml?: XmlType; // endregion choice @@ -812,13 +819,13 @@ export class FormulaType extends XMLElement { super(el); // choice - if (el.latex) this.latex = new XMLElement(el.latex); + if (el.latex) this.latex = new DCCXMLElement(el.latex); else if (el.mathml) this.mathml = new XmlType(el.mathml); } } /** This data block is used to add user or application specific XML content. */ -export class XmlType extends XMLElement { +export class XmlType extends DCCXMLElement { constructor(el: Partial<XmlType> = {}) { super(el); } @@ -828,7 +835,7 @@ export class XmlType extends XMLElement { * Additionally used methods, used software, influence conditions that only affect this quantity can be * added. * Measurement metadata can also be added. */ -export class QuantityType extends XMLElement { +export class QuantityType extends DCCXMLElement { name?: TextType; description?: RichContentType; @@ -870,7 +877,7 @@ export class QuantityType extends XMLElement { * - si:list elements and * - si:realList elements and * - si:complexList elements */ - list?: si.ListType; + list?: si.SIListType; /** The hybrid elements allows to add quantities to the * machine readable D-SI format, with other units, than those allowed * to be used with the SI by means of the BIPM SI brochure. @@ -991,7 +998,7 @@ export class QuantityType extends XMLElement { // choice if (el.noQuantity) this.noQuantity = new RichContentType(el.noQuantity); else if (el.real) this.real = new si.RealQuantityType(el.real); - else if (el.list) this.list = new si.ListType(el.list); + else if (el.list) this.list = new si.SIListType(el.list); else if (el.hybrid) this.hybrid = new si.HybridType(el.hybrid); else if (el.complex) this.complex = new si.ComplexQuantityType(el.complex); else if (el.constant) this.constant = new si.ConstantQuantityType(el.constant); @@ -1012,7 +1019,7 @@ export class QuantityType extends XMLElement { * matrix and tensor structures as well as structures of higher dimension. The 'list' * may also be used to give measurement results in combination with some * ambient conditions at the measurement. */ -export class ListType extends XMLElement { +export class ListType extends DCCXMLElement { name?: TextType; description?: RichContentType; usedMethods?: UsedMethodListType; @@ -1022,8 +1029,8 @@ export class ListType extends XMLElement { measurementMetaData?: MeasurementMetaDataListType; // region choice - dateTime?: XMLDate; - dateTimeXMLList?: XMLList; + dateTime?: DCCXMLDate; + dateTimeXMLList?: DCCXMLList; // endregion choice // region choice @@ -1043,8 +1050,8 @@ export class ListType extends XMLElement { if (el.measurementMetaData) this.measurementMetaData = new MeasurementMetaDataListType(el.measurementMetaData); // choice - if (el.dateTime) this.dateTime = new XMLDate(el.dateTime); - else if (el.dateTimeXMLList) this.dateTimeXMLList = new XMLList(el.dateTimeXMLList); + if (el.dateTime) this.dateTime = new DCCXMLDate(el.dateTime); + else if (el.dateTimeXMLList) this.dateTimeXMLList = new DCCXMLList(el.dateTimeXMLList); // choice if (el.list) this.list = ensureArray(el.list).map((x) => new ListType(x)); @@ -1052,7 +1059,7 @@ export class ListType extends XMLElement { } } -export class RelativeUncertaintyType extends XMLElement { +export class RelativeUncertaintyType extends DCCXMLElement { // region choice relativeUncertaintyXmlList?: si.RealListXMLListType; relativeUncertainty?: si.RealQuantityType; @@ -1069,40 +1076,40 @@ export class RelativeUncertaintyType extends XMLElement { } /** A string element with an additional lang attribute for localization. */ -export class StringWithLangType extends XMLElement { +export class StringWithLangType extends DCCXMLElement { constructor(el: Partial<StringWithLangType> = {}) { super(el); } } -export class LocationType extends XMLElement { - city: XMLElement[]; - countryCode: XMLElement[]; - postCode: XMLElement[]; - postOfficeBox: XMLElement[]; - state: XMLElement[]; - street: XMLElement[]; - streetNo: XMLElement[]; +export class LocationType extends DCCXMLElement { + city: DCCXMLElement[]; + countryCode: DCCXMLElement[]; + postCode: DCCXMLElement[]; + postOfficeBox: DCCXMLElement[]; + state: DCCXMLElement[]; + street: DCCXMLElement[]; + streetNo: DCCXMLElement[]; further: RichContentType[]; positionCoordinates: PositionCoordinatesType[]; constructor(el: Partial<LocationType> = {}) { super(el); - this.city = ensureArray(el.city).map((x) => new XMLElement(x)); - this.countryCode = ensureArray(el.countryCode).map((x) => new XMLElement(x)); - this.postCode = ensureArray(el.postCode).map((x) => new XMLElement(x)); - this.postOfficeBox = ensureArray(el.postOfficeBox).map((x) => new XMLElement(x)); - this.state = ensureArray(el.state).map((x) => new XMLElement(x)); - this.street = ensureArray(el.street).map((x) => new XMLElement(x)); - this.streetNo = ensureArray(el.streetNo).map((x) => new XMLElement(x)); + this.city = ensureArray(el.city).map((x) => new DCCXMLElement(x)); + this.countryCode = ensureArray(el.countryCode).map((x) => new DCCXMLElement(x)); + this.postCode = ensureArray(el.postCode).map((x) => new DCCXMLElement(x)); + this.postOfficeBox = ensureArray(el.postOfficeBox).map((x) => new DCCXMLElement(x)); + this.state = ensureArray(el.state).map((x) => new DCCXMLElement(x)); + this.street = ensureArray(el.street).map((x) => new DCCXMLElement(x)); + this.streetNo = ensureArray(el.streetNo).map((x) => new DCCXMLElement(x)); this.further = ensureArray(el.further).map((x) => new RichContentType(x)); this.positionCoordinates = ensureArray(el.positionCoordinates).map((x) => new PositionCoordinatesType(x)); } } -export class PositionCoordinatesType extends XMLElement { - positionCoordinateSystem: XMLElement; - reference?: XMLElement; +export class PositionCoordinatesType extends DCCXMLElement { + positionCoordinateSystem: DCCXMLElement; + reference?: DCCXMLElement; declaration?: RichContentType; positionCoordinate1: si.RealQuantityType; positionCoordinate2: si.RealQuantityType; @@ -1110,8 +1117,8 @@ export class PositionCoordinatesType extends XMLElement { constructor(el: Partial<PositionCoordinatesType> = {}) { super(el); - this.positionCoordinateSystem = new XMLElement(el.positionCoordinateSystem); - if (el.reference) this.reference = new XMLElement(el.reference); + this.positionCoordinateSystem = new DCCXMLElement(el.positionCoordinateSystem); + if (el.reference) this.reference = new DCCXMLElement(el.reference); if (el.declaration) this.declaration = new RichContentType(el.declaration); this.positionCoordinate1 = new si.RealQuantityType(el.positionCoordinate1); this.positionCoordinate2 = new si.RealQuantityType(el.positionCoordinate2); diff --git a/src/DCCDocument.ts b/src/DCCDocument.ts index 8936778b50d668873cfbb46168113409fc987d43..065f7aec87cb669ec30bb952870f5982a47ec4c2 100644 --- a/src/DCCDocument.ts +++ b/src/DCCDocument.ts @@ -40,7 +40,7 @@ export class DCCDocument { elementNameFn: function (val, currentElementObj) { // eslint-disable-next-line @typescript-eslint/no-explicit-any const currentElement = <any>currentElementObj; - return `${typeof currentElement?.getNamespace === "function" ? currentElement.getNamespace() : ""}:${val}`; + return `${currentElement?.namespace ? `${currentElement.namespace}:` : ""}${val}`; }, }); } diff --git a/src/SI.ts b/src/DSI.ts similarity index 58% rename from src/SI.ts rename to src/DSI.ts index ae1cc86aadcb0ac98e8f237c1e6d050d88c2e76b..9846e56ea9fd5e88fc4d454b1ec0090801f16048 100644 --- a/src/SI.ts +++ b/src/DSI.ts @@ -1,59 +1,70 @@ -import { XMLDate as BaseXMLDate, XMLElement as BaseXMLElement, XMLBoolean as BaseXMLBoolean, XMLNumber as BaseXMLNumber, XMLList as BaseXMLList } from "./BaseTypes"; +import { XMLDate, XMLElement, XMLBoolean, XMLNumber, XMLList, INamespaced, ISchemaInformation } from "./BaseTypes"; import { ensureArray } from "./Util"; -export const schemaVersion = "2.1.0"; -export const namespace = `https://ptb.de/si`; -export const schemaLocation = `${namespace}/v${schemaVersion}/SI_Format.xsd`; - -export class XMLElement extends BaseXMLElement { - getNamespace() { - return "si"; +const schemaVersion = "2.1.0"; +const namespace = "si"; +const namespaceUrl = `https://ptb.de/${namespace}`; +const schemaLocation = `${namespaceUrl}/v${schemaVersion}/SI_Format.xsd`; +export const DSI: ISchemaInformation = { + schemaVersion, + namespace, + namespaceUrl, + schemaLocation, +}; + +export class SIXMLElement extends XMLElement implements INamespaced { + get namespace() { + return DSI.namespace; } } -export class XMLBoolean extends BaseXMLBoolean { getNamespace() { return "si"; }} +export class SIXMLBoolean extends XMLBoolean implements INamespaced { + get namespace() { + return DSI.namespace; + } +} -export class XMLDate extends BaseXMLDate { - getNamespace() { - return "si"; +export class SIXMLDate extends XMLDate implements INamespaced { + get namespace() { + return DSI.namespace; } } -export class XMLNumber extends BaseXMLNumber { - getNamespace() { - return "si"; +export class SIXMLNumber extends XMLNumber implements INamespaced { + get namespace() { + return DSI.namespace; } } -export class XMLList extends BaseXMLList { - getNamespace() { - return "si"; +export class SIXMLList extends XMLList implements INamespaced { + get namespace() { + return DSI.namespace; } } -export class RealQuantityType extends XMLElement { - label?: XMLElement; - value: XMLNumber; - unit: XMLElement; - dateTime?: XMLDate; +export class RealQuantityType extends SIXMLElement implements INamespaced { + label?: SIXMLElement; + value: SIXMLNumber; + unit: SIXMLElement; + dateTime?: SIXMLDate; expandedUnc?: ExpandedUncType; coverageInterval?: CoverageIntervalType; constructor(el: Partial<RealQuantityType> = {}) { super(el); - if (el.label) this.label = new XMLElement(el.label); - this.value = new XMLNumber(el.value); - this.unit = new XMLElement(el.unit); - if (el.dateTime) this.dateTime = new XMLDate(el.dateTime); + if (el.label) this.label = new SIXMLElement(el.label); + this.value = new SIXMLNumber(el.value); + this.unit = new SIXMLElement(el.unit); + if (el.dateTime) this.dateTime = new SIXMLDate(el.dateTime); if (el.expandedUnc) this.expandedUnc = new ExpandedUncType(el.expandedUnc); if (el.coverageInterval) this.coverageInterval = new CoverageIntervalType(el.coverageInterval); } } -export class HybridType extends XMLElement { +export class HybridType extends SIXMLElement { real: RealQuantityType[]; complex: ComplexQuantityType[]; - list: ListType[]; + list: SIListType[]; realList: RealListType[]; realListXMLList: RealListXMLListType[]; complexList: ComplexListType[]; @@ -63,7 +74,7 @@ export class HybridType extends XMLElement { super(el); this.real = ensureArray(el.real).map((x) => new RealQuantityType(x)); this.complex = ensureArray(el.complex).map((x) => new ComplexQuantityType(x)); - this.list = ensureArray(el.list).map((x) => new ListType(x)); + this.list = ensureArray(el.list).map((x) => new SIListType(x)); this.realList = ensureArray(el.realList).map((x) => new RealListType(x)); this.realListXMLList = ensureArray(el.realListXMLList).map((x) => new RealListXMLListType(x)); this.complexList = ensureArray(el.complexList).map((x) => new ComplexListType(x)); @@ -71,53 +82,53 @@ export class HybridType extends XMLElement { } } -export class ComplexQuantityType extends XMLElement { - label?: XMLElement; - dateTime?: XMLDate; - valueReal: XMLNumber; - valueImag: XMLNumber; - unit: XMLElement[]; - valueMagnitude: XMLNumber; - valuePhase: XMLNumber; - unitPhase: XMLElement; +export class ComplexQuantityType extends SIXMLElement { + label?: SIXMLElement; + dateTime?: SIXMLDate; + valueReal: SIXMLNumber; + valueImag: SIXMLNumber; + unit: SIXMLElement[]; + valueMagnitude: SIXMLNumber; + valuePhase: SIXMLNumber; + unitPhase: SIXMLElement; ellipsoidalRegion?: EllipsoidalRegionType; rectangularRegion?: RectangularRegionType; constructor(el: Partial<ComplexQuantityType> = {}) { super(el); - if (el.label) this.label = new XMLElement(el.label); - if (el.dateTime) this.dateTime = new XMLDate(el.dateTime); - this.valueReal = new XMLNumber(el.valueReal); - this.valueImag = new XMLNumber(el.valueImag); - this.unit = ensureArray(el.unit).map((x) => new XMLElement(x)); - this.valueMagnitude = new XMLNumber(el.valueMagnitude); - this.valuePhase = new XMLNumber(el.valuePhase); - this.unitPhase = new XMLElement(el.unitPhase); + if (el.label) this.label = new SIXMLElement(el.label); + if (el.dateTime) this.dateTime = new SIXMLDate(el.dateTime); + this.valueReal = new SIXMLNumber(el.valueReal); + this.valueImag = new SIXMLNumber(el.valueImag); + this.unit = ensureArray(el.unit).map((x) => new SIXMLElement(x)); + this.valueMagnitude = new SIXMLNumber(el.valueMagnitude); + this.valuePhase = new SIXMLNumber(el.valuePhase); + this.unitPhase = new SIXMLElement(el.unitPhase); if (el.ellipsoidalRegion) this.ellipsoidalRegion = new EllipsoidalRegionType(el.ellipsoidalRegion); if (el.rectangularRegion) this.rectangularRegion = new RectangularRegionType(el.rectangularRegion); } } -export class ConstantQuantityType extends XMLElement { - label?: XMLElement; - value: XMLNumber; - unit: XMLElement; - dateTime?: XMLDate; - uncertainty?: XMLNumber; - distribution?: XMLElement; +export class ConstantQuantityType extends SIXMLElement { + label?: SIXMLElement; + value: SIXMLNumber; + unit: SIXMLElement; + dateTime?: SIXMLDate; + uncertainty?: SIXMLNumber; + distribution?: SIXMLElement; constructor(el: Partial<ConstantQuantityType> = {}) { super(el); - if (el.label) this.label = new XMLElement(el.label); - this.value = new XMLNumber(el.value); - this.unit = new XMLElement(el.unit); - if (el.dateTime) this.dateTime = new XMLDate(el.dateTime); - if (el.uncertainty) this.uncertainty = new XMLNumber(el.uncertainty); - if (el.distribution) this.distribution = new XMLElement(el.distribution); + if (el.label) this.label = new SIXMLElement(el.label); + this.value = new SIXMLNumber(el.value); + this.unit = new SIXMLElement(el.unit); + if (el.dateTime) this.dateTime = new SIXMLDate(el.dateTime); + if (el.uncertainty) this.uncertainty = new SIXMLNumber(el.uncertainty); + if (el.distribution) this.distribution = new SIXMLElement(el.distribution); } } -export class RealListXMLListType extends XMLElement { +export class RealListXMLListType extends SIXMLElement { labelXMLList?: StringXMLListType; valueXMLList: DecimalXMLListType; unitXMLList: UnitXMLListType; @@ -140,135 +151,135 @@ export class RealListXMLListType extends XMLElement { } } -export class ListType extends XMLElement { - label?: XMLElement; - dateTime?: XMLDate; +export class SIListType extends SIXMLElement { + label?: SIXMLElement; + dateTime?: SIXMLDate; realList: RealListType[]; complexList: ComplexListType[]; - list: ListType[]; + list: SIListType[]; - constructor(el: Partial<ListType> = {}) { + constructor(el: Partial<SIListType> = {}) { super(el); - if (el.label) this.label = new XMLElement(el.label); - if (el.dateTime) this.dateTime = new XMLDate(el.dateTime); + if (el.label) this.label = new SIXMLElement(el.label); + if (el.dateTime) this.dateTime = new SIXMLDate(el.dateTime); this.realList = ensureArray(el.realList).map((x) => new RealListType(x)); this.complexList = ensureArray(el.complexList).map((x) => new ComplexListType(x)); - this.list = ensureArray(el.list).map((x) => new ListType(x)); + this.list = ensureArray(el.list).map((x) => new SIListType(x)); } } -export class ExpandedUncType extends XMLElement { - uncertainty: XMLNumber; - coverageFactor: XMLNumber; - coverageProbability: XMLNumber; - distribution?: XMLElement; +export class ExpandedUncType extends SIXMLElement { + uncertainty: SIXMLNumber; + coverageFactor: SIXMLNumber; + coverageProbability: SIXMLNumber; + distribution?: SIXMLElement; constructor(el: Partial<ExpandedUncType> = {}) { super(el); - this.uncertainty = new XMLNumber(el.uncertainty); - this.coverageFactor = new XMLNumber(el.coverageFactor); - this.coverageProbability = new XMLNumber(el.coverageProbability); - if (el.distribution) this.distribution = new XMLElement(el.distribution); + this.uncertainty = new SIXMLNumber(el.uncertainty); + this.coverageFactor = new SIXMLNumber(el.coverageFactor); + this.coverageProbability = new SIXMLNumber(el.coverageProbability); + if (el.distribution) this.distribution = new SIXMLElement(el.distribution); } } -export class CoverageIntervalType extends XMLElement { - standardUnc: XMLNumber; - intervalMin: XMLNumber; - intervalMax: XMLNumber; - coverageProbability: XMLNumber; - distribution?: XMLElement; +export class CoverageIntervalType extends SIXMLElement { + standardUnc: SIXMLNumber; + intervalMin: SIXMLNumber; + intervalMax: SIXMLNumber; + coverageProbability: SIXMLNumber; + distribution?: SIXMLElement; constructor(el: Partial<CoverageIntervalType> = {}) { super(el); - this.standardUnc = new XMLNumber(el.standardUnc); - this.intervalMin = new XMLNumber(el.intervalMin); - this.intervalMax = new XMLNumber(el.intervalMax); - this.coverageProbability = new XMLNumber(el.coverageProbability); - if (el.distribution) this.distribution = new XMLElement(el.distribution); + this.standardUnc = new SIXMLNumber(el.standardUnc); + this.intervalMin = new SIXMLNumber(el.intervalMin); + this.intervalMax = new SIXMLNumber(el.intervalMax); + this.coverageProbability = new SIXMLNumber(el.coverageProbability); + if (el.distribution) this.distribution = new SIXMLElement(el.distribution); } } -export class EllipsoidalRegionType extends XMLElement { +export class EllipsoidalRegionType extends SIXMLElement { covarianceMatrix: CovarianceMatrixType; - coverageFactor: XMLNumber; - coverageProbability: XMLNumber; - distribution?: XMLElement; + coverageFactor: SIXMLNumber; + coverageProbability: SIXMLNumber; + distribution?: SIXMLElement; constructor(el: Partial<EllipsoidalRegionType> = {}) { super(el); this.covarianceMatrix = new CovarianceMatrixType(el.covarianceMatrix); - this.coverageFactor = new XMLNumber(el.coverageFactor); - this.coverageProbability = new XMLNumber(el.coverageProbability); - if (el.distribution) this.distribution = new XMLElement(el.distribution); + this.coverageFactor = new SIXMLNumber(el.coverageFactor); + this.coverageProbability = new SIXMLNumber(el.coverageProbability); + if (el.distribution) this.distribution = new SIXMLElement(el.distribution); } } -export class RectangularRegionType extends XMLElement { +export class RectangularRegionType extends SIXMLElement { covarianceMatrix: CovarianceMatrixType; - coverageFactor: XMLNumber; - coverageProbability: XMLNumber; - distribution?: XMLElement; + coverageFactor: SIXMLNumber; + coverageProbability: SIXMLNumber; + distribution?: SIXMLElement; constructor(el: Partial<RectangularRegionType> = {}) { super(el); this.covarianceMatrix = new CovarianceMatrixType(el.covarianceMatrix); - this.coverageFactor = new XMLNumber(el.coverageFactor); - this.coverageProbability = new XMLNumber(el.coverageProbability); - if (el.distribution) this.distribution = new XMLElement(el.distribution); + this.coverageFactor = new SIXMLNumber(el.coverageFactor); + this.coverageProbability = new SIXMLNumber(el.coverageProbability); + if (el.distribution) this.distribution = new SIXMLElement(el.distribution); } } -export class RealInListType extends XMLElement { - label?: XMLElement; - value: XMLNumber; - unit?: XMLElement; - dateTime?: XMLDate; +export class RealInListType extends SIXMLElement { + label?: SIXMLElement; + value: SIXMLNumber; + unit?: SIXMLElement; + dateTime?: SIXMLDate; expandedUnc?: ExpandedUncType; coverageInterval?: CoverageIntervalType; constructor(el: Partial<RealInListType> = {}) { super(el); - if (el.label) this.label = new XMLElement(el.label); - this.value = new XMLNumber(el.value); - if (el.unit) this.unit = new XMLElement(el.unit); - if (el.dateTime) this.dateTime = new XMLDate(el.dateTime); + if (el.label) this.label = new SIXMLElement(el.label); + this.value = new SIXMLNumber(el.value); + if (el.unit) this.unit = new SIXMLElement(el.unit); + if (el.dateTime) this.dateTime = new SIXMLDate(el.dateTime); if (el.expandedUnc) this.expandedUnc = new ExpandedUncType(el.expandedUnc); if (el.coverageInterval) this.coverageInterval = new CoverageIntervalType(el.coverageInterval); } } -export class ComplexInListType extends XMLElement { - label?: XMLElement; - dateTime?: XMLDate; - valueReal: XMLNumber; - valueImag: XMLNumber; - unit?: XMLElement[]; - valueMagnitude: XMLNumber; - valuePhase: XMLNumber; - unitPhase?: XMLElement; +export class ComplexInListType extends SIXMLElement { + label?: SIXMLElement; + dateTime?: SIXMLDate; + valueReal: SIXMLNumber; + valueImag: SIXMLNumber; + unit?: SIXMLElement[]; + valueMagnitude: SIXMLNumber; + valuePhase: SIXMLNumber; + unitPhase?: SIXMLElement; ellipsoidalRegion?: EllipsoidalRegionType; rectangularRegion?: RectangularRegionType; constructor(el: Partial<ComplexInListType> = {}) { super(el); - if (el.label) this.label = new XMLElement(el.label); - if (el.dateTime) this.dateTime = new XMLDate(el.dateTime); - this.valueReal = new XMLNumber(el.valueReal); - this.valueImag = new XMLNumber(el.valueImag); - if (el.unit) this.unit = ensureArray(el.unit).map((x) => new XMLElement(x)); - this.valueMagnitude = new XMLNumber(el.valueMagnitude); - this.valuePhase = new XMLNumber(el.valuePhase); - if (el.unitPhase) this.unitPhase = new XMLElement(el.unitPhase); + if (el.label) this.label = new SIXMLElement(el.label); + if (el.dateTime) this.dateTime = new SIXMLDate(el.dateTime); + this.valueReal = new SIXMLNumber(el.valueReal); + this.valueImag = new SIXMLNumber(el.valueImag); + if (el.unit) this.unit = ensureArray(el.unit).map((x) => new SIXMLElement(x)); + this.valueMagnitude = new SIXMLNumber(el.valueMagnitude); + this.valuePhase = new SIXMLNumber(el.valuePhase); + if (el.unitPhase) this.unitPhase = new SIXMLElement(el.unitPhase); if (el.ellipsoidalRegion) this.ellipsoidalRegion = new EllipsoidalRegionType(el.ellipsoidalRegion); if (el.rectangularRegion) this.rectangularRegion = new RectangularRegionType(el.rectangularRegion); } } -export class RealListType extends XMLElement { - label?: XMLElement; - dateTime?: XMLDate; - listUnit?: XMLElement; +export class RealListType extends SIXMLElement { + label?: SIXMLElement; + dateTime?: SIXMLDate; + listUnit?: SIXMLElement; /** Definition of a structure, for a global univariate uncertainty, that * is used within the list structure with a list of real quantities. * The global univariate uncertainty can either be given as an expanded @@ -284,9 +295,9 @@ export class RealListType extends XMLElement { constructor(el: Partial<RealListType> = {}) { super(el); - if (el.label) this.label = new XMLElement(el.label); - if (el.dateTime) this.dateTime = new XMLDate(el.dateTime); - if (el.listUnit) this.listUnit = new XMLElement(el.listUnit); + if (el.label) this.label = new SIXMLElement(el.label); + if (el.dateTime) this.dateTime = new SIXMLDate(el.dateTime); + if (el.listUnit) this.listUnit = new SIXMLElement(el.listUnit); if (el.listUnivariateUnc) this.listUnivariateUnc = new ListUnivariateUncType(el.listUnivariateUnc); this.real = ensureArray(el.real).map((x) => new RealInListType(x)); if (el.ellipsoidalRegion) this.ellipsoidalRegion = new EllipsoidalRegionType(el.ellipsoidalRegion); @@ -294,7 +305,7 @@ export class RealListType extends XMLElement { } } -export class ListUnivariateUncType extends XMLElement { +export class ListUnivariateUncType extends SIXMLElement { expandedUnc: ExpandedUncType; coverageInterval: CoverageIntervalType; @@ -307,21 +318,21 @@ export class ListUnivariateUncType extends XMLElement { /** Type providing listing of strings (xs:string) * with separation by blank spaces. */ -export class StringXMLListType extends XMLList {} +export class StringXMLListType extends SIXMLList {} /** Type providing listing of values (si:decimalType) * with separation by blank spaces. */ -export class DecimalXMLListType extends XMLList {} +export class DecimalXMLListType extends SIXMLList {} /** Type providing listing of units (si:unitType) * with separation by blank spaces. */ -export class UnitXMLListType extends XMLList {} +export class UnitXMLListType extends SIXMLList {} /** Type providing listing of time values (xs:dateTime) * with separation by blank spaces. */ -export class DateTimeXMLListType extends XMLList {} +export class DateTimeXMLListType extends SIXMLList {} -export class ExpandedUncXMLListType extends XMLElement { +export class ExpandedUncXMLListType extends SIXMLElement { uncertaintyXMLList: UncertaintyValueXMLListType; coverageFactorXMLList: KValueXMLListType; coverageProbabilityXMLList: ProbabilityValueXMLListType; @@ -336,7 +347,7 @@ export class ExpandedUncXMLListType extends XMLElement { } } -export class CoverageIntervalXMLListType extends XMLElement { +export class CoverageIntervalXMLListType extends SIXMLElement { standardUncXMLList: UncertaintyValueXMLListType; intervalMinXMLList: DecimalXMLListType; intervalMaxXMLList: DecimalXMLListType; @@ -353,11 +364,11 @@ export class CoverageIntervalXMLListType extends XMLElement { } } -export class ComplexListType extends XMLElement { - label?: XMLElement; - dateTime?: XMLDate; - listUnit?: XMLElement; - listUnitPhase?: XMLElement; +export class ComplexListType extends SIXMLElement { + label?: SIXMLElement; + dateTime?: SIXMLDate; + listUnit?: SIXMLElement; + listUnitPhase?: SIXMLElement; /** Definition of a structure, for a global bivariate uncertainty, that * is used within the list structure with a list of complex quantities. * The global bivariate uncertainty can either be given as a hyper-ellipsoidal @@ -374,10 +385,10 @@ export class ComplexListType extends XMLElement { constructor(el: Partial<ComplexListType> = {}) { super(el); - if (el.label) this.label = new XMLElement(el.label); - if (el.dateTime) this.dateTime = new XMLDate(el.dateTime); - if (el.listUnit) this.listUnit = new XMLElement(el.listUnit); - if (el.listUnitPhase) this.listUnitPhase = new XMLElement(el.listUnitPhase); + if (el.label) this.label = new SIXMLElement(el.label); + if (el.dateTime) this.dateTime = new SIXMLDate(el.dateTime); + if (el.listUnit) this.listUnit = new SIXMLElement(el.listUnit); + if (el.listUnitPhase) this.listUnitPhase = new SIXMLElement(el.listUnitPhase); if (el.listBivariateUnc) this.listBivariateUnc = new ListBivariateUncType(el.listBivariateUnc); this.complex = ensureArray(el.complex).map((x) => new ComplexInListType(x)); if (el.ellipsoidalRegion) this.ellipsoidalRegion = new EllipsoidalRegionType(el.ellipsoidalRegion); @@ -385,7 +396,7 @@ export class ComplexListType extends XMLElement { } } -export class ListBivariateUncType extends XMLElement { +export class ListBivariateUncType extends SIXMLElement { ellipsoidalRegion?: EllipsoidalRegionType; rectangularRegion?: RectangularRegionType; @@ -398,17 +409,17 @@ export class ListBivariateUncType extends XMLElement { /** Type providing listing of uncertainty values (si:uncertaintyValueType) * with separation by blank spaces. */ -export class UncertaintyValueXMLListType extends XMLList {} +export class UncertaintyValueXMLListType extends SIXMLList {} /** Type providing listing of coverage factor values (si:kValueType) * with separation by blank spaces. */ -export class KValueXMLListType extends XMLList {} +export class KValueXMLListType extends SIXMLList {} /** Type providing listing of coverage probability values (si:probabilityValueType) * with separation by blank spaces. */ -export class ProbabilityValueXMLListType extends XMLList {} +export class ProbabilityValueXMLListType extends SIXMLList {} -export class CovarianceMatrixType extends XMLElement { +export class CovarianceMatrixType extends SIXMLElement { /** Definition of a column in the covariance matrix. * * The column has n covariance elements, where @@ -425,7 +436,7 @@ export class CovarianceMatrixType extends XMLElement { } } -export class CovarianceMatrixTypeColumnType extends XMLElement { +export class CovarianceMatrixTypeColumnType extends SIXMLElement { /** Each covariance component is defined by * - element value (decimal value type) * - element unit (string - SI format) */ @@ -437,13 +448,13 @@ export class CovarianceMatrixTypeColumnType extends XMLElement { } } -export class CovarianceMatrixTypeColumnTypeCovarianceType extends XMLElement { - value: XMLNumber; - unit: XMLElement; +export class CovarianceMatrixTypeColumnTypeCovarianceType extends SIXMLElement { + value: SIXMLNumber; + unit: SIXMLElement; constructor(el: Partial<CovarianceMatrixTypeColumnTypeCovarianceType> = {}) { super(el); - this.value = new XMLNumber(el.value); - this.unit = new XMLElement(el.unit); + this.value = new SIXMLNumber(el.value); + this.unit = new SIXMLElement(el.unit); } } diff --git a/src/index.ts b/src/index.ts index 803a18c6066e0e6b809c800eccee542a4e129a89..42089998d99397bec32af34ac89dce2feea7c415 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ export * from "./Util"; export * from "./DCCDocument"; export * from "./DCC"; -export * as SI from "./SI"; +export * from "./DSI";