|
@@ -10,7 +10,6 @@ import { XMLElem, type IToXML } from '@/util/XmlElem';
|
|
|
export class UANodeSet implements IToXML{
|
|
|
|
|
|
constructor(public fileName: string,
|
|
|
- public uri: string,
|
|
|
public models: Model[],
|
|
|
public nodes: UABaseNode[],
|
|
|
public nameSpaceTable: NamespaceTable) {
|
|
@@ -58,12 +57,13 @@ export class UANodeSet implements IToXML{
|
|
|
isArray: (name, jpath, isLeafNode, isAttribute):boolean => {
|
|
|
switch(jpath) {
|
|
|
case 'UANodeSet.NamespaceUris.Uri':
|
|
|
- case 'UANodeSet.UAObject.References.Reference':
|
|
|
+ case 'UANodeSet.Models.Model':
|
|
|
case 'UANodeSet.UAObject':
|
|
|
- case 'UANodeSet.UAVariable':
|
|
|
+ case 'UANodeSet.UAObject.References.Reference':
|
|
|
case 'UANodeSet.UAMethod':
|
|
|
+ case 'UANodeSet.UAMethod.References.Reference':
|
|
|
+ case 'UANodeSet.UAVariable':
|
|
|
case 'UANodeSet.UAVariable.References.Reference':
|
|
|
- case 'UANodeSet.Models.Model':
|
|
|
return true;
|
|
|
default:
|
|
|
return false;
|
|
@@ -73,31 +73,28 @@ export class UANodeSet implements IToXML{
|
|
|
const parser = new XMLParser(parseOptions);
|
|
|
const xmlObj = parser.parse(xml);
|
|
|
const models: Model[]=[];
|
|
|
- const xmlModels=xmlObj['UANodeSet']['Models'];
|
|
|
+ const xmlModels=xmlObj['UANodeSet']['Models']||[];
|
|
|
for(const xmlModel of xmlModels.Model) {
|
|
|
models.push(Model.fromXML(xmlModel));
|
|
|
}
|
|
|
- let uri = "xxx";
|
|
|
const nodes:UABaseNode[]=[];
|
|
|
- const xmlObjects=xmlObj['UANodeSet']['UAObject'];
|
|
|
+ const xmlObjects=xmlObj['UANodeSet']['UAObject']||[];
|
|
|
for(const xmlObject of xmlObjects) {
|
|
|
nodes.push(UAObject.fromXML(xmlObject));
|
|
|
}
|
|
|
- const xmlVariables=xmlObj['UANodeSet']['UAVariable'];
|
|
|
+ const xmlVariables=xmlObj['UANodeSet']['UAVariable']||[];
|
|
|
for(const xmlVariable of xmlVariables) {
|
|
|
nodes.push(UAVariable.fromXML(xmlVariable));
|
|
|
}
|
|
|
- const xmlMethods=xmlObj['UANodeSet']['UAMethod'];
|
|
|
+ const xmlMethods=xmlObj['UANodeSet']['UAMethod']||[];
|
|
|
for(const xmlMethod of xmlMethods) {
|
|
|
nodes.push(UAMethod.fromXML(xmlMethod));
|
|
|
}
|
|
|
- const uaNamespaceUris=xmlObj['UANodeSet']['NamespaceUris'];
|
|
|
+ const uaNamespaceUris=xmlObj['UANodeSet']['NamespaceUris']||[];
|
|
|
const nst=new NamespaceTable();
|
|
|
- if(uaNamespaceUris) {
|
|
|
- for(const nsUri of uaNamespaceUris['Uri']) {
|
|
|
- nst.addUri(nsUri['#text'])
|
|
|
- }
|
|
|
+ for(const nsUri of uaNamespaceUris['Uri']||[]) {
|
|
|
+ nst.addUri(nsUri['#text'])
|
|
|
}
|
|
|
- return new UANodeSet(fileName, uri, models, nodes, nst);
|
|
|
+ return new UANodeSet(fileName, models, nodes, nst);
|
|
|
}
|
|
|
}
|