Skip to content

Commit

Permalink
improve loadnodeset
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Nov 12, 2023
1 parent 0243c5a commit 19b8863
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,21 @@ export async function generateAddressSpaceRaw(

const nodesetDesc = await preLoad(xmlFiles, xmlLoader);
const order = findOrder(nodesetDesc);

// register namespace in the same order as specified in the xmlFiles array
for (let index = 0; index < order.length; index++) {
const nodesetIndex = order[index];
const nodeset = nodesetDesc[nodesetIndex];
debugLog(" loading ", nodesetIndex, nodeset.xmlData.length);
for (const model of nodeset.namespaceModel.models) {
const n = nodesetDesc[index];
for (const model of n.namespaceModel.models) {
const ns = addressSpace.registerNamespace(model.modelUri) as NamespacePrivate;
ns.setRequiredModels(model.requiredModel);
}
}


for (let index = 0; index < order.length; index++) {
const nodesetIndex = order[index];
const nodeset = nodesetDesc[nodesetIndex];
debugLog(" loading ", nodesetIndex, nodeset.xmlData.length);
try {
await nodesetLoader.addNodeSetAsync(nodeset.xmlData);
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo

// istanbul ignore next
if (namespaceIndex === undefined) {
debugLog("Warning: namespace_uri_translation = ", namespace_uri_translation);
errorLog("namespace_uri_translation", namespace_uri_translation);
errorLog("Warning: namespace_uri_translation = ", namespace_uri_translation);
errorLog("Error; namespace_uri_translation", namespace_uri_translation);
throw new Error("_translateNamespaceIndex() ! Cannot find namespace definition for index " + innerIndex);
}
return namespaceIndex;
Expand Down

0 comments on commit 19b8863

Please sign in to comment.