|
@@ -9,6 +9,7 @@ import { XMLElem, type IToXML } from '@/util/XmlElem';
|
|
|
import { UAReferenceType } from './UAReferenceType';
|
|
|
import { UAObjectType } from './UAObjectType';
|
|
|
import { UAVariableType } from './UAVariableType';
|
|
|
+import type { AddressSpace } from './AddressSpace';
|
|
|
|
|
|
export class UANodeSet implements IToXML{
|
|
|
|
|
@@ -53,12 +54,12 @@ export class UANodeSet implements IToXML{
|
|
|
return xmlUANodeSet;
|
|
|
}
|
|
|
|
|
|
- static async load(url: string): Promise<UANodeSet> {
|
|
|
+ static async load(url: string, addressSpace: AddressSpace): Promise<UANodeSet> {
|
|
|
const xml= await (await fetch(url)).text();
|
|
|
const fileName= url.split('/').pop()||url
|
|
|
- return this.parse(xml, fileName);
|
|
|
+ return this.parse(xml, fileName, addressSpace);
|
|
|
}
|
|
|
- static async parse(xml: string, fileName: string): Promise<UANodeSet> {
|
|
|
+ static async parse(xml: string, fileName: string, addressSpace: AddressSpace): Promise<UANodeSet> {
|
|
|
const parseOptions:Partial<X2jOptions>={
|
|
|
ignoreAttributes: false,
|
|
|
alwaysCreateTextNode: true, //force consistent result
|
|
@@ -96,27 +97,27 @@ export class UANodeSet implements IToXML{
|
|
|
const nodes:UABaseNode[]=[];
|
|
|
const xmlObjects=xmlObj['UANodeSet']['UAObject']||[];
|
|
|
for(const xmlObject of xmlObjects) {
|
|
|
- nodes.push(UAObject.fromXML(xmlObject));
|
|
|
+ nodes.push(UAObject.fromXML(xmlObject, addressSpace));
|
|
|
}
|
|
|
const xmlVariables=xmlObj['UANodeSet']['UAVariable']||[];
|
|
|
for(const xmlVariable of xmlVariables) {
|
|
|
- nodes.push(UAVariable.fromXML(xmlVariable));
|
|
|
+ nodes.push(UAVariable.fromXML(xmlVariable, addressSpace));
|
|
|
}
|
|
|
const xmlMethods=xmlObj['UANodeSet']['UAMethod']||[];
|
|
|
for(const xmlMethod of xmlMethods) {
|
|
|
- nodes.push(UAMethod.fromXML(xmlMethod));
|
|
|
+ nodes.push(UAMethod.fromXML(xmlMethod, addressSpace));
|
|
|
}
|
|
|
const xmlReferenceTypes=xmlObj['UANodeSet']['UAReferenceType']||[];
|
|
|
for(const xmlReferenceType of xmlReferenceTypes) {
|
|
|
- nodes.push(UAReferenceType.fromXML(xmlReferenceType));
|
|
|
+ nodes.push(UAReferenceType.fromXML(xmlReferenceType, addressSpace));
|
|
|
}
|
|
|
const xmlObjectTypes=xmlObj['UANodeSet']['UAObjectType']||[];
|
|
|
for(const xmlObjectType of xmlObjectTypes) {
|
|
|
- nodes.push(UAObjectType.fromXML(xmlObjectType));
|
|
|
+ nodes.push(UAObjectType.fromXML(xmlObjectType, addressSpace));
|
|
|
}
|
|
|
const xmlVariableTypes=xmlObj['UANodeSet']['UAVariableType']||[];
|
|
|
for(const xmlVariableType of xmlVariableTypes) {
|
|
|
- nodes.push(UAVariableType.fromXML(xmlVariableType));
|
|
|
+ nodes.push(UAVariableType.fromXML(xmlVariableType, addressSpace));
|
|
|
}
|
|
|
const uaNamespaceUris=xmlObj['UANodeSet']['NamespaceUris']||[];
|
|
|
const nst=new NamespaceTable();
|