node-opcua-address-space 2.181.1 → 2.182.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/api/helpers/ensure_secure_access.ts +53 -2
  2. package/api/index.ts +30 -1
  3. package/api/loader/generateAddressSpaceRaw.ts +44 -139
  4. package/api/loader/load_nodeset2.ts +5 -0
  5. package/api/loader/narrow_instance_datatypes.ts +264 -0
  6. package/api/loader/nodeset_builtin_formats.ts +143 -0
  7. package/api/loader/nodeset_format.ts +153 -0
  8. package/api/loader/nodeset_image.ts +37 -4
  9. package/api/loader/nodeset_image_codec.ts +153 -34
  10. package/api/loader/nodeset_record.ts +26 -2
  11. package/api/loader/nodeset_record_applier.ts +54 -3
  12. package/api/loader/nodeset_records_to_xml.ts +620 -0
  13. package/api/loader/nodeset_source.ts +185 -26
  14. package/api/loader/nodeset_to_image.ts +16 -5
  15. package/api/loader/nodeset_xml_header.ts +119 -0
  16. package/api/loader/nodeset_xml_primitives.ts +209 -0
  17. package/api/loader/nodeset_xml_producer.ts +61 -2
  18. package/api/loader/parsers/variant_parser.ts +9 -0
  19. package/bin/nodeset_equivalence.js +750 -0
  20. package/bin/nodeset_tool_common.js +72 -0
  21. package/bin/opcua-nodeset-image.js +93 -103
  22. package/bin/opcua-nodeset-live.js +139 -0
  23. package/dist/api/helpers/ensure_secure_access.d.ts +20 -0
  24. package/dist/api/helpers/ensure_secure_access.js +39 -0
  25. package/dist/api/helpers/ensure_secure_access.js.map +1 -1
  26. package/dist/api/index.d.ts +7 -2
  27. package/dist/api/index.js +21 -1
  28. package/dist/api/index.js.map +1 -1
  29. package/dist/api/loader/generateAddressSpaceRaw.d.ts +1 -7
  30. package/dist/api/loader/generateAddressSpaceRaw.js +32 -125
  31. package/dist/api/loader/generateAddressSpaceRaw.js.map +1 -1
  32. package/dist/api/loader/load_nodeset2.js +4 -0
  33. package/dist/api/loader/load_nodeset2.js.map +1 -1
  34. package/dist/api/loader/narrow_instance_datatypes.d.ts +30 -0
  35. package/dist/api/loader/narrow_instance_datatypes.js +217 -0
  36. package/dist/api/loader/narrow_instance_datatypes.js.map +1 -0
  37. package/dist/api/loader/nodeset_builtin_formats.d.ts +27 -0
  38. package/dist/api/loader/nodeset_builtin_formats.js +133 -0
  39. package/dist/api/loader/nodeset_builtin_formats.js.map +1 -0
  40. package/dist/api/loader/nodeset_format.d.ts +123 -0
  41. package/dist/api/loader/nodeset_format.js +63 -0
  42. package/dist/api/loader/nodeset_format.js.map +1 -0
  43. package/dist/api/loader/nodeset_image.d.ts +17 -1
  44. package/dist/api/loader/nodeset_image.js +32 -4
  45. package/dist/api/loader/nodeset_image.js.map +1 -1
  46. package/dist/api/loader/nodeset_image_codec.d.ts +4 -0
  47. package/dist/api/loader/nodeset_image_codec.js +142 -53
  48. package/dist/api/loader/nodeset_image_codec.js.map +1 -1
  49. package/dist/api/loader/nodeset_record.d.ts +26 -2
  50. package/dist/api/loader/nodeset_record.js +11 -2
  51. package/dist/api/loader/nodeset_record.js.map +1 -1
  52. package/dist/api/loader/nodeset_record_applier.js +52 -3
  53. package/dist/api/loader/nodeset_record_applier.js.map +1 -1
  54. package/dist/api/loader/nodeset_records_to_xml.d.ts +16 -0
  55. package/dist/api/loader/nodeset_records_to_xml.js +536 -0
  56. package/dist/api/loader/nodeset_records_to_xml.js.map +1 -0
  57. package/dist/api/loader/nodeset_source.d.ts +68 -7
  58. package/dist/api/loader/nodeset_source.js +157 -20
  59. package/dist/api/loader/nodeset_source.js.map +1 -1
  60. package/dist/api/loader/nodeset_to_image.d.ts +4 -4
  61. package/dist/api/loader/nodeset_to_image.js +14 -4
  62. package/dist/api/loader/nodeset_to_image.js.map +1 -1
  63. package/dist/api/loader/nodeset_xml_header.d.ts +22 -0
  64. package/dist/api/loader/nodeset_xml_header.js +113 -0
  65. package/dist/api/loader/nodeset_xml_header.js.map +1 -0
  66. package/dist/api/loader/nodeset_xml_primitives.d.ts +37 -0
  67. package/dist/api/loader/nodeset_xml_primitives.js +196 -0
  68. package/dist/api/loader/nodeset_xml_primitives.js.map +1 -0
  69. package/dist/api/loader/nodeset_xml_producer.js +56 -1
  70. package/dist/api/loader/nodeset_xml_producer.js.map +1 -1
  71. package/dist/api/loader/parsers/variant_parser.js +7 -0
  72. package/dist/api/loader/parsers/variant_parser.js.map +1 -1
  73. package/dist/impl/_instantiate_helpers.js +1 -0
  74. package/dist/impl/_instantiate_helpers.js.map +1 -1
  75. package/dist/impl/alarms_and_conditions/ua_alarm_condition_impl.js +4 -0
  76. package/dist/impl/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
  77. package/dist/impl/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +14 -0
  78. package/dist/impl/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
  79. package/dist/impl/base_node_impl.d.ts +9 -0
  80. package/dist/impl/base_node_impl.js +11 -0
  81. package/dist/impl/base_node_impl.js.map +1 -1
  82. package/dist/impl/base_node_private.js +67 -97
  83. package/dist/impl/base_node_private.js.map +1 -1
  84. package/dist/impl/nodeset_tools/construct_namespace_dependency.js +5 -1
  85. package/dist/impl/nodeset_tools/construct_namespace_dependency.js.map +1 -1
  86. package/dist/impl/nodeset_tools/nodeset_to_records.js +61 -15
  87. package/dist/impl/nodeset_tools/nodeset_to_records.js.map +1 -1
  88. package/dist/impl/nodeset_tools/nodeset_to_xml.d.ts +1 -8
  89. package/dist/impl/nodeset_tools/nodeset_to_xml.js +174 -190
  90. package/dist/impl/nodeset_tools/nodeset_to_xml.js.map +1 -1
  91. package/dist/impl/ua_data_type_impl.d.ts +21 -0
  92. package/dist/impl/ua_data_type_impl.js +27 -2
  93. package/dist/impl/ua_data_type_impl.js.map +1 -1
  94. package/dist/impl/ua_object_type_impl.d.ts +9 -0
  95. package/dist/impl/ua_object_type_impl.js +12 -1
  96. package/dist/impl/ua_object_type_impl.js.map +1 -1
  97. package/dist/impl/ua_variable_impl.js +27 -10
  98. package/dist/impl/ua_variable_impl.js.map +1 -1
  99. package/dist/impl/ua_variable_impl_ext_obj.js +19 -2
  100. package/dist/impl/ua_variable_impl_ext_obj.js.map +1 -1
  101. package/dist/impl/ua_variable_type_impl.d.ts +8 -1
  102. package/dist/impl/ua_variable_type_impl.js +39 -2
  103. package/dist/impl/ua_variable_type_impl.js.map +1 -1
  104. package/dist/tsconfig_base.tsbuildinfo +1 -1
  105. package/distNodeJS/generate_address_space.js +4 -0
  106. package/distNodeJS/generate_address_space.js.map +1 -1
  107. package/impl/_instantiate_helpers.ts +3 -0
  108. package/impl/alarms_and_conditions/ua_alarm_condition_impl.ts +10 -0
  109. package/impl/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +17 -0
  110. package/impl/base_node_impl.ts +15 -0
  111. package/impl/base_node_private.ts +97 -146
  112. package/impl/nodeset_tools/construct_namespace_dependency.ts +5 -1
  113. package/impl/nodeset_tools/nodeset_to_records.ts +66 -16
  114. package/impl/nodeset_tools/nodeset_to_xml.ts +127 -160
  115. package/impl/ua_data_type_impl.ts +40 -2
  116. package/impl/ua_object_type_impl.ts +16 -3
  117. package/impl/ua_variable_impl.ts +27 -10
  118. package/impl/ua_variable_impl_ext_obj.ts +20 -2
  119. package/impl/ua_variable_type_impl.ts +48 -2
  120. package/package.json +29 -27
  121. package/source_nodejs/generate_address_space.ts +7 -1
@@ -7,12 +7,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7
7
  return (mod && mod.__esModule) ? mod : { "default": mod };
8
8
  };
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.initXmlWriterEx = initXmlWriterEx;
10
+ exports.makeTypeXsd = exports.initXmlWriterEx = exports.coerceInt64ToInt32 = void 0;
11
11
  exports._dumpVariantExtensionObjectValue_Body = _dumpVariantExtensionObjectValue_Body;
12
12
  exports._isDefaultValue = _isDefaultValue;
13
- exports.coerceInt64ToInt32 = coerceInt64ToInt32;
14
13
  exports.sortByBrowseName = sortByBrowseName;
15
- exports.makeTypeXsd = makeTypeXsd;
16
14
  const node_util_1 = require("node:util");
17
15
  const node_opcua_assert_1 = require("node-opcua-assert");
18
16
  const node_opcua_basic_types_1 = require("node-opcua-basic-types");
@@ -20,11 +18,13 @@ const node_opcua_constants_1 = require("node-opcua-constants");
20
18
  const node_opcua_data_model_1 = require("node-opcua-data-model");
21
19
  const node_opcua_debug_1 = require("node-opcua-debug");
22
20
  const node_opcua_nodeid_1 = require("node-opcua-nodeid");
21
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
23
22
  const node_opcua_types_1 = require("node-opcua-types");
24
23
  const node_opcua_utils_1 = require("node-opcua-utils");
25
24
  const node_opcua_variant_1 = require("node-opcua-variant");
26
25
  const xml_writer_1 = __importDefault(require("xml-writer"));
27
26
  const decode_xml_extension_object_js_1 = require("../../api/loader/decode_xml_extension_object.js");
27
+ const nodeset_xml_primitives_js_1 = require("../../api/loader/nodeset_xml_primitives.js");
28
28
  const session_context_js_1 = require("../../api/session_context.js");
29
29
  const base_node_impl_js_1 = require("../base_node_impl.js");
30
30
  const namespace_impl_js_1 = require("../namespace_impl.js");
@@ -35,6 +35,10 @@ const ua_object_type_impl_js_1 = require("../ua_object_type_impl.js");
35
35
  const ua_variable_impl_js_1 = require("../ua_variable_impl.js");
36
36
  const construct_namespace_dependency_js_1 = require("./construct_namespace_dependency.js");
37
37
  const nodeset_to_records_js_1 = require("./nodeset_to_records.js");
38
+ var nodeset_xml_primitives_js_2 = require("../../api/loader/nodeset_xml_primitives.js");
39
+ Object.defineProperty(exports, "coerceInt64ToInt32", { enumerable: true, get: function () { return nodeset_xml_primitives_js_2.coerceInt64ToInt32; } });
40
+ Object.defineProperty(exports, "initXmlWriterEx", { enumerable: true, get: function () { return nodeset_xml_primitives_js_2.initXmlWriterEx; } });
41
+ Object.defineProperty(exports, "makeTypeXsd", { enumerable: true, get: function () { return nodeset_xml_primitives_js_2.makeTypeXsd; } });
38
42
  const debugLog = (0, node_opcua_debug_1.make_debugLog)("nodeset_to_xml");
39
43
  const warningLog = (0, node_opcua_debug_1.make_warningLog)("nodeset_to_xml");
40
44
  const errorLog = (0, node_opcua_debug_1.make_errorLog)("nodeset_to_xml");
@@ -56,24 +60,6 @@ function _dumpDescription(xw, node) {
56
60
  xw.startElement("Description").text(desc).endElement();
57
61
  }
58
62
  }
59
- function translateNodeId(xw, nodeId) {
60
- (0, node_opcua_assert_1.assert)(nodeId instanceof node_opcua_nodeid_1.NodeId);
61
- const nn = xw.translationTable.get(nodeId.namespace);
62
- const translatedNode = new node_opcua_nodeid_1.NodeId(nodeId.identifierType, nodeId.value, nn);
63
- return translatedNode;
64
- }
65
- function n(xw, nodeId) {
66
- return translateNodeId(xw, nodeId).toString().replace("ns=0;", "");
67
- }
68
- function translateBrowseName(xw, browseName) {
69
- (0, node_opcua_assert_1.assert)(browseName instanceof node_opcua_data_model_1.QualifiedName);
70
- const nn = xw.translationTable.get(browseName.namespaceIndex);
71
- const translatedBrowseName = new node_opcua_data_model_1.QualifiedName({ namespaceIndex: nn, name: browseName.name });
72
- return translatedBrowseName;
73
- }
74
- function b(xw, browseName) {
75
- return translateBrowseName(xw, browseName).toString().replace("ns=0;", "");
76
- }
77
63
  function hasHigherPriorityThan(namespaceIndex1, namespaceIndex2, priorityTable) {
78
64
  const order1 = priorityTable[namespaceIndex1];
79
65
  const order2 = priorityTable[namespaceIndex2];
@@ -106,6 +92,7 @@ function _dumpReferences(xw, node) {
106
92
  // below already tolerates it being absent.
107
93
  const connectsToReferenceType = addressSpace.findReferenceType("ConnectsTo");
108
94
  const hasEventSourceReferenceType = _mustFindReferenceType(addressSpace, "HasEventSource");
95
+ const hierarchicalReferencesType = _mustFindReferenceType(addressSpace, "HierarchicalReferences");
109
96
  function referenceToKeep(reference) {
110
97
  // resolved here: a reference nobody has looked at since the load carries only the NodeId of its type
111
98
  const referenceType = reference_impl_js_1.ReferenceImpl.resolveReferenceType(addressSpace, reference);
@@ -145,12 +132,30 @@ function _dumpReferences(xw, node) {
145
132
  // Organizes inverse — the current node is organized by an external folder
146
133
  return true;
147
134
  }
135
+ else if (referenceType.isSubtypeOf(organizesReferencesType) && reference.isForward) {
136
+ // Organizes forward into another namespace: the target lives in a document this export
137
+ // does not write, so nothing else will ever declare this reference and dropping it
138
+ // loses it outright. Within our own namespace the target declares the inverse and this
139
+ // end stays silent, exactly as the Aggregates branch above decides it
140
+ return targetedNamespaceIndex !== node.nodeId.namespace;
141
+ }
148
142
  else if (connectsToReferenceType && referenceType.isSubtypeOf(connectsToReferenceType) && reference.isForward) {
149
143
  return true;
150
144
  }
151
145
  else if (referenceType.isSubtypeOf(hasEventSourceReferenceType) && reference.isForward) {
152
146
  return true;
153
147
  }
148
+ else if (referenceType.isSubtypeOf(hierarchicalReferencesType)) {
149
+ // a hierarchical reference type the branches above do not name: a companion
150
+ // specification's own, such as Robotics' Requires, Controls and HasSafetyStates. Those
151
+ // fell through to `return false` and were dropped in both directions, so a nodeset that
152
+ // defines its own hierarchical reference type lost every reference that used it.
153
+ // Decided the way Aggregates is decided just above: this end writes the reference
154
+ // unless the other end has the higher priority and will write it instead
155
+ return reference.isForward
156
+ ? !_hasHigherPriorityThan(xw, targetedNamespaceIndex, node.nodeId.namespace)
157
+ : targetedNamespaceIndex !== node.nodeId.namespace;
158
+ }
154
159
  return false;
155
160
  }
156
161
  const allReferences = node.allReferences();
@@ -160,105 +165,32 @@ function _dumpReferences(xw, node) {
160
165
  continue;
161
166
  }
162
167
  xw.startElement("Reference");
163
- xw.writeAttribute("ReferenceType", b(xw, (0, base_node_impl_js_1.getReferenceType)(reference).browseName));
168
+ xw.writeAttribute("ReferenceType", (0, nodeset_xml_primitives_js_1.b)(xw, (0, base_node_impl_js_1.getReferenceType)(reference).browseName));
164
169
  if (!reference.isForward) {
165
170
  xw.writeAttribute("IsForward", reference.isForward ? "true" : "false");
166
171
  }
167
- xw.text(n(xw, reference.nodeId));
168
- xw.endElement();
169
- }
170
- xw.endElement();
171
- }
172
- function _dumpLocalizedText(xw, v) {
173
- const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
174
- if (v.locale?.length) {
175
- xw.startElement(`${uax}Locale`);
176
- xw.text(v.locale);
172
+ xw.text((0, nodeset_xml_primitives_js_1.n)(xw, reference.nodeId));
177
173
  xw.endElement();
178
174
  }
179
- xw.startElement(`${uax}Text`);
180
- if (v.text) {
181
- xw.text(v.text);
182
- }
183
- xw.endElement();
184
- }
185
- function _dumpQualifiedName(xw, v) {
186
- const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
187
- const t = translateBrowseName(xw, v);
188
- if (t.name) {
189
- xw.startElement(`${uax}Name`);
190
- xw.text(t.name);
191
- xw.endElement();
192
- }
193
- if (t.namespaceIndex) {
194
- xw.startElement(`${uax}NamespaceIndex`);
195
- xw.text(t.namespaceIndex.toString());
196
- xw.endElement();
197
- }
198
- }
199
- function _dumpXmlElement(xw, v) {
200
- xw.text(v);
201
- }
202
- function initXmlWriterEx(xw, map, namespaceArray) {
203
- const xwe = xw;
204
- xwe.map = map;
205
- xwe.stackMap = [];
206
- xwe.namespaceArray = namespaceArray;
207
- }
208
- function findXsdNamespaceUri(xw, nodeId) {
209
- const xwe = xw;
210
- if (!xwe.namespaceArray) {
211
- return "";
212
- }
213
- const namespace = xwe.namespaceArray[nodeId.namespace];
214
- if (namespace === "http://opcfoundation.org/UA/") {
215
- return "http://opcfoundation.org/UA/2008/02/Types.xsd";
216
- }
217
- // c8 ignore next
218
- if (!namespace) {
219
- return "";
220
- }
221
- return `${namespace.replace(/\/$/, "")}/Types.xsd`;
222
- }
223
- function getPrefix(xw, namespace) {
224
- const xwe = xw;
225
- if (!xwe.map)
226
- return "";
227
- const p = xwe.map[namespace] || "";
228
- return p ? `${p}:` : "";
229
- }
230
- function restoreDefaultNamespace(xw) {
231
- const xwe = xw;
232
- if (!xwe.map)
233
- return;
234
- const previousMap = xwe.stackMap.pop();
235
- if (previousMap) {
236
- xwe.map = previousMap;
237
- }
238
- }
239
- function setDefaultNamespace(xw, namespace) {
240
- const xwe = xw;
241
- if (!xwe.map)
242
- return;
243
- if (xwe.map[namespace] !== "") {
244
- xw.writeAttribute("xmlns", namespace);
245
- }
246
- xwe.stackMap.push({
247
- ...xwe.map
248
- });
249
- xwe.map[namespace] = "";
250
- }
251
- function startElementEx(xw, _ns, name, defaultNamespace) {
252
- const _xwe = xw;
253
- xw.startElement(name);
254
- setDefaultNamespace(xw, defaultNamespace);
255
- }
256
- function _dumpNodeId(xw, v) {
257
- const xmlns = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
258
- xw.startElement(`${xmlns}Identifier`);
259
- xw.text(n(xw, v));
260
175
  xw.endElement();
261
176
  }
177
+ /*
178
+ <uax:ExtensionObject>
179
+ <uax:TypeId>
180
+ <uax:Identifier>i=339</uax:Identifier>
181
+ </uax:TypeId>
182
+ <uax:Body>
183
+ <BuildInfo xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
184
+ <ProductUri></ProductUri>
185
+ <ManufacturerName></ManufacturerName>
186
+ <ProductName></ProductName>
187
+ <SoftwareVersion></SoftwareVersion>
188
+ <BuildNumber></BuildNumber>
189
+ <BuildDate>1900-01-01T00:00:00Z</BuildDate>
190
+ </BuildInfo>
191
+ </uax:Body>
192
+ </uax:ExtensionObject>
193
+ */
262
194
  function _dumpVariantValue(xw, dataTypeNodeId, dataType, addressSpace, value) {
263
195
  if (value === undefined || value === null) {
264
196
  return;
@@ -266,15 +198,15 @@ function _dumpVariantValue(xw, dataTypeNodeId, dataType, addressSpace, value) {
266
198
  if (dataType === node_opcua_variant_1.DataType.Null) {
267
199
  return;
268
200
  }
269
- const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
201
+ const uax = (0, nodeset_xml_primitives_js_1.getPrefix)(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
270
202
  xw.startElement(`${uax}${node_opcua_variant_1.DataType[dataType]}`);
271
203
  const definitionMap = (0, decode_xml_extension_object_js_1.makeDefinitionMap)(addressSpace);
272
204
  _dumpVariantInnerValue(xw, dataType, dataTypeNodeId, definitionMap, addressSpace, value);
273
205
  xw.endElement();
274
206
  }
275
207
  function _dumpVariantInnerExtensionObject(xw, definitionMap, definition, addressSpace, value) {
276
- const namespaceUri = findXsdNamespaceUri(xw, definition.defaultEncodingId);
277
- const ns = getPrefix(xw, namespaceUri);
208
+ const namespaceUri = (0, nodeset_xml_primitives_js_1.findXsdNamespaceUri)(xw, definition.defaultEncodingId);
209
+ const ns = (0, nodeset_xml_primitives_js_1.getPrefix)(xw, namespaceUri);
278
210
  const isUnion = definition.structureType === node_opcua_types_1.StructureType.Union || definition.structureType === node_opcua_types_1.StructureType.UnionWithSubtypedValues;
279
211
  for (const field of definition.fields || []) {
280
212
  const dataTypeNodeId = field.dataType;
@@ -289,7 +221,7 @@ function _dumpVariantInnerExtensionObject(xw, definitionMap, definition, address
289
221
  continue; // ns=0;i=0 is reserved
290
222
  }
291
223
  const { name, definition } = definitionMap.findDefinition(dataTypeNodeId);
292
- startElementEx(xw, ns, fieldName, namespaceUri);
224
+ (0, nodeset_xml_primitives_js_1.startElementEx)(xw, ns, fieldName, namespaceUri);
293
225
  // xw.startElement(fieldName);
294
226
  let fun = (_value) => {
295
227
  /** */
@@ -336,14 +268,14 @@ function _dumpVariantInnerExtensionObject(xw, definitionMap, definition, address
336
268
  }
337
269
  // throw err;
338
270
  }
339
- restoreDefaultNamespace(xw);
271
+ (0, nodeset_xml_primitives_js_1.restoreDefaultNamespace)(xw);
340
272
  xw.endElement();
341
273
  }
342
274
  else {
343
275
  if (!isUnion && !field.isOptional) {
344
276
  // field is mandatory but is null=> provide an empty array
345
- startElementEx(xw, ns, fieldName, namespaceUri);
346
- restoreDefaultNamespace(xw);
277
+ (0, nodeset_xml_primitives_js_1.startElementEx)(xw, ns, fieldName, namespaceUri);
278
+ (0, nodeset_xml_primitives_js_1.restoreDefaultNamespace)(xw);
347
279
  xw.endElement();
348
280
  }
349
281
  }
@@ -357,26 +289,26 @@ function _dumpVariantInnerValueEnum(xw, definition, value) {
357
289
  xw.text(`${field?.name}_${field?.value[1]}`);
358
290
  }
359
291
  function _dumpVariantInnerValue(xw, dataType, dataTypeNodeId, definitionMap, addressSpace, value) {
360
- const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
292
+ const uax = (0, nodeset_xml_primitives_js_1.getPrefix)(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
361
293
  switch (dataType) {
362
294
  case null:
363
295
  case node_opcua_variant_1.DataType.Null:
364
296
  break;
365
297
  case node_opcua_variant_1.DataType.LocalizedText:
366
- _dumpLocalizedText(xw, value);
298
+ (0, nodeset_xml_primitives_js_1._dumpLocalizedText)(xw, value);
367
299
  break;
368
300
  case node_opcua_variant_1.DataType.QualifiedName:
369
- _dumpQualifiedName(xw, value);
301
+ (0, nodeset_xml_primitives_js_1._dumpQualifiedName)(xw, value);
370
302
  break;
371
303
  case node_opcua_variant_1.DataType.NodeId:
372
- _dumpNodeId(xw, value);
304
+ (0, nodeset_xml_primitives_js_1._dumpNodeId)(xw, value);
373
305
  break;
374
306
  case node_opcua_variant_1.DataType.DateTime:
375
307
  xw.text(value.toISOString());
376
308
  break;
377
309
  case node_opcua_variant_1.DataType.Int64:
378
310
  case node_opcua_variant_1.DataType.UInt64:
379
- xw.text(value[1].toString());
311
+ xw.text((0, nodeset_xml_primitives_js_1.int64ToDecimalString)(value, dataType === node_opcua_variant_1.DataType.Int64));
380
312
  break;
381
313
  case node_opcua_variant_1.DataType.Boolean:
382
314
  case node_opcua_variant_1.DataType.SByte:
@@ -414,7 +346,7 @@ function _dumpVariantInnerValue(xw, dataType, dataTypeNodeId, definitionMap, add
414
346
  _dumpVariantExtensionObjectValue(xw, dataTypeNodeId, definitionMap, addressSpace, value);
415
347
  break;
416
348
  case node_opcua_variant_1.DataType.XmlElement:
417
- _dumpXmlElement(xw, value);
349
+ (0, nodeset_xml_primitives_js_1._dumpXmlElement)(xw, value);
418
350
  break;
419
351
  case node_opcua_variant_1.DataType.StatusCode:
420
352
  xw.text(value.value.toString());
@@ -438,13 +370,13 @@ function _dumpVariantInnerValue(xw, dataType, dataTypeNodeId, definitionMap, add
438
370
  */
439
371
  function _dumpVariantExtensionObjectValue_Body(xw, definitionMap, name, definition, addressSpace, value) {
440
372
  if (value) {
441
- const namespaceUri = findXsdNamespaceUri(xw, definition.defaultEncodingId);
442
- const ns = getPrefix(xw, namespaceUri);
443
- startElementEx(xw, ns, `${name}`, namespaceUri);
373
+ const namespaceUri = (0, nodeset_xml_primitives_js_1.findXsdNamespaceUri)(xw, definition.defaultEncodingId);
374
+ const ns = (0, nodeset_xml_primitives_js_1.getPrefix)(xw, namespaceUri);
375
+ (0, nodeset_xml_primitives_js_1.startElementEx)(xw, ns, `${name}`, namespaceUri);
444
376
  if (value) {
445
377
  _dumpVariantInnerExtensionObject(xw, definitionMap, definition, addressSpace, value);
446
378
  }
447
- restoreDefaultNamespace(xw);
379
+ (0, nodeset_xml_primitives_js_1.restoreDefaultNamespace)(xw);
448
380
  xw.endElement();
449
381
  }
450
382
  }
@@ -457,23 +389,23 @@ function _dumpVariantExtensionObjectValue(xw, dataTypeNodeId, definitionMap, add
457
389
  // throw new Error("Extension Object doesn't provide a XML ");
458
390
  return;
459
391
  }
460
- const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
461
- startElementEx(xw, uax, `ExtensionObject`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
392
+ const uax = (0, nodeset_xml_primitives_js_1.getPrefix)(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
393
+ (0, nodeset_xml_primitives_js_1.startElementEx)(xw, uax, `ExtensionObject`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
462
394
  {
463
- const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
395
+ const uax = (0, nodeset_xml_primitives_js_1.getPrefix)(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
464
396
  xw.startElement(`${uax}TypeId`);
465
397
  // find HasEncoding node
466
398
  // xx var encodingDefaultXml = schema.encodingDefaultXml;
467
399
  xw.startElement(`${uax}Identifier`);
468
- xw.text(n(xw, encodingDefaultXml));
400
+ xw.text((0, nodeset_xml_primitives_js_1.n)(xw, encodingDefaultXml));
469
401
  xw.endElement();
470
402
  xw.endElement();
471
- startElementEx(xw, uax, "Body", "http://opcfoundation.org/UA/2008/02/Types.xsd");
403
+ (0, nodeset_xml_primitives_js_1.startElementEx)(xw, uax, "Body", "http://opcfoundation.org/UA/2008/02/Types.xsd");
472
404
  _dumpVariantExtensionObjectValue_Body(xw, definitionMap, name, definition, addressSpace, value);
473
- restoreDefaultNamespace(xw);
405
+ (0, nodeset_xml_primitives_js_1.restoreDefaultNamespace)(xw);
474
406
  xw.endElement();
475
407
  }
476
- restoreDefaultNamespace(xw);
408
+ (0, nodeset_xml_primitives_js_1.restoreDefaultNamespace)(xw);
477
409
  xw.endElement();
478
410
  }
479
411
  function _dumpVariantExtensionObjectValue2(xw, addressSpace, value) {
@@ -526,7 +458,7 @@ function _isDefaultValue(value) {
526
458
  break;
527
459
  case node_opcua_variant_1.DataType.Int64:
528
460
  case node_opcua_variant_1.DataType.UInt64:
529
- if (0 === coerceInt64ToInt32(value.value)) {
461
+ if (0 === (0, nodeset_xml_primitives_js_1.coerceInt64ToInt32)(value.value)) {
530
462
  return true;
531
463
  }
532
464
  break;
@@ -565,7 +497,6 @@ function _dumpValue(xw, node, variant) {
565
497
  doDebug && debugLog("Cannot find dataType:", node.dataType.toString());
566
498
  return;
567
499
  }
568
- const dataTypeName = dataTypeNode.browseName.name?.toString();
569
500
  const baseDataTypeName = node_opcua_variant_1.DataType[variant.dataType];
570
501
  if (baseDataTypeName === "Null") {
571
502
  return;
@@ -573,19 +504,22 @@ function _dumpValue(xw, node, variant) {
573
504
  (0, node_opcua_assert_1.assert)(typeof baseDataTypeName === "string");
574
505
  // determine if dataTypeName is a ExtensionObject
575
506
  const isExtensionObject = variant.dataType === node_opcua_variant_1.DataType.ExtensionObject;
576
- if (_isDefaultValue(variant)) {
507
+ // nothing to serialize: a scalar with no value, or an array that is null rather than empty.
508
+ // This is the one thing _isDefaultValue used to catch here that still needs catching -- it is
509
+ // a test for the absence of a value, not for a value that happens to equal a type's default
510
+ if (variant.value === null || variant.value === undefined) {
577
511
  return;
578
512
  }
579
513
  xw.startElement("Value");
580
- const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
514
+ const uax = (0, nodeset_xml_primitives_js_1.getPrefix)(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
581
515
  if (isExtensionObject) {
582
516
  const encodeXml = _dumpVariantExtensionObjectValue2.bind(null, xw, node.addressSpace);
583
517
  switch (variant.arrayType) {
584
518
  case node_opcua_variant_1.VariantArrayType.Matrix:
585
519
  case node_opcua_variant_1.VariantArrayType.Array:
586
- startElementEx(xw, uax, `ListOf${baseDataTypeName}`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
520
+ (0, nodeset_xml_primitives_js_1.startElementEx)(xw, uax, `ListOf${baseDataTypeName}`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
587
521
  variant.value.forEach(encodeXml);
588
- restoreDefaultNamespace(xw);
522
+ (0, nodeset_xml_primitives_js_1.restoreDefaultNamespace)(xw);
589
523
  xw.endElement();
590
524
  break;
591
525
  case node_opcua_variant_1.VariantArrayType.Scalar:
@@ -601,9 +535,13 @@ function _dumpValue(xw, node, variant) {
601
535
  switch (variant.arrayType) {
602
536
  case node_opcua_variant_1.VariantArrayType.Matrix:
603
537
  case node_opcua_variant_1.VariantArrayType.Array:
604
- startElementEx(xw, uax, `ListOf${dataTypeName}`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
538
+ // the built-in type, not the DataType's browse name: the uax schema defines
539
+ // ListOfInt32 and ListOfString, and nothing named after a nodeset's own DataType.
540
+ // A `ListOfIdType` is not an element any reader knows, so the reader that meets it
541
+ // walks straight past into the first child and takes the array for a scalar
542
+ (0, nodeset_xml_primitives_js_1.startElementEx)(xw, uax, `ListOf${baseDataTypeName}`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
605
543
  variant.value.forEach(encodeXml);
606
- restoreDefaultNamespace(xw);
544
+ (0, nodeset_xml_primitives_js_1.restoreDefaultNamespace)(xw);
607
545
  xw.endElement();
608
546
  break;
609
547
  case node_opcua_variant_1.VariantArrayType.Scalar:
@@ -617,12 +555,17 @@ function _dumpValue(xw, node, variant) {
617
555
  xw.endElement();
618
556
  }
619
557
  function _dumpArrayDimensionsAttribute(xw, node) {
620
- if (node.arrayDimensions) {
621
- if (node.valueRank === -1 || (node.arrayDimensions.length === 1 && node.arrayDimensions[0] === 0)) {
622
- return;
623
- }
624
- xw.writeAttribute("ArrayDimensions", node.arrayDimensions.join(","));
625
- }
558
+ // ArrayDimensions="0" is written only when the document declared it: node-opcua synthesizes [0]
559
+ // on the variables it generates, so writing it unconditionally would invent the attribute on
560
+ // every generated node. See arrayDimensionsWereDeclared in nodeset_record_applier
561
+ if (!node.arrayDimensions || node.valueRank <= 0)
562
+ return;
563
+ // all-zero dimensions are what node-opcua synthesizes when nobody declared any, at whatever
564
+ // rank: [0] for a one-dimensional value, [0,0] for a matrix
565
+ const degenerate = node.arrayDimensions.every((d) => d === 0);
566
+ if (degenerate && !node.arrayDimensionsWereDeclared)
567
+ return;
568
+ xw.writeAttribute("ArrayDimensions", node.arrayDimensions.join(","));
626
569
  }
627
570
  function getParent(node) {
628
571
  if (node instanceof ua_variable_impl_js_1.UAVariableImpl || node instanceof ua_method_impl_js_1.UAMethodImpl || node instanceof ua_object_impl_js_1.UAObjectImpl) {
@@ -632,17 +575,21 @@ function getParent(node) {
632
575
  }
633
576
  const currentReadFlag = (0, node_opcua_data_model_1.makeAccessLevelFlag)("CurrentRead");
634
577
  function dumpCommonAttributes(xw, node) {
635
- xw.writeAttribute("NodeId", n(xw, node.nodeId));
636
- xw.writeAttribute("BrowseName", b(xw, node.browseName));
578
+ xw.writeAttribute("NodeId", (0, nodeset_xml_primitives_js_1.n)(xw, node.nodeId));
579
+ xw.writeAttribute("BrowseName", (0, nodeset_xml_primitives_js_1.b)(xw, node.browseName));
637
580
  const parentNode = getParent(node);
638
581
  if (parentNode) {
639
582
  if (parentNode.nodeId.namespace <= node.nodeId.namespace) {
640
- xw.writeAttribute("ParentNodeId", n(xw, parentNode.nodeId));
583
+ xw.writeAttribute("ParentNodeId", (0, nodeset_xml_primitives_js_1.n)(xw, parentNode.nodeId));
641
584
  }
642
585
  }
643
586
  if (Object.hasOwn(node, "symbolicName")) {
644
587
  xw.writeAttribute("SymbolicName", node.symbolicName);
645
588
  }
589
+ // Released is the default and is left unwritten; the other two the document declared
590
+ if (node.releaseStatus) {
591
+ xw.writeAttribute("ReleaseStatus", node.releaseStatus);
592
+ }
646
593
  if (Object.hasOwn(node, "isAbstract")) {
647
594
  const isAbstract = node.isAbstract;
648
595
  if (isAbstract) {
@@ -667,8 +614,11 @@ function dumpCommonAttributes(xw, node) {
667
614
  }
668
615
  // access policy: undefined means "inherit from the namespace", an empty rolePermissions array
669
616
  // means "this node deliberately grants nothing".
670
- if (node.accessRestrictions !== undefined) {
671
- xw.writeAttribute("AccessRestrictions", node.accessRestrictions.toString());
617
+ // what the document declared, which survives whatever the loader was asked to enforce; the
618
+ // enforced flag is the fallback for a node built in code rather than loaded
619
+ const accessRestrictions = node.declaredAccessRestrictions ?? node.accessRestrictions?.toString();
620
+ if (accessRestrictions !== undefined) {
621
+ xw.writeAttribute("AccessRestrictions", accessRestrictions);
672
622
  }
673
623
  if (node.rolePermissions !== undefined && node.rolePermissions.length === 0) {
674
624
  xw.writeAttribute("HasNoPermissions", "true");
@@ -679,6 +629,19 @@ function dumpCommonAttributes(xw, node) {
679
629
  xw.writeAttribute("MinimumSamplingInterval", minimumSamplingInterval);
680
630
  }
681
631
  }
632
+ // EventNotifier lives on UAObject, UAObjectType and UAView in the XSD. 0 is the default and is
633
+ // left unwritten; anything else the document declared. It was written nowhere at all until now,
634
+ // so every node that declared one lost it on the way out
635
+ if (node.nodeClass === node_opcua_data_model_1.NodeClass.Object || node.nodeClass === node_opcua_data_model_1.NodeClass.ObjectType || node.nodeClass === node_opcua_data_model_1.NodeClass.View) {
636
+ // typeof, not truthiness: a node with a child called "EventNotifier" resolves the name to
637
+ // that child through the shared child accessors, so `node.eventNotifier` is a BaseNode
638
+ // there and not the attribute. PublishedEventsType is one, and stringifying it wrote a
639
+ // whole node dump into the attribute
640
+ const eventNotifier = node.eventNotifier;
641
+ if (typeof eventNotifier === "number" && eventNotifier !== 0) {
642
+ xw.writeAttribute("EventNotifier", eventNotifier.toString());
643
+ }
644
+ }
682
645
  // Historizing exists in the XSD on UAVariable only: UAVariableType is restricted to
683
646
  // DataType/ValueRank/ArrayDimensions. UAVariableTypeImpl nevertheless owns a `historizing`
684
647
  // property, so the node class must be tested here rather than the presence of the property.
@@ -699,7 +662,7 @@ function _dumpRolePermissions(xw, node) {
699
662
  for (const rolePermission of rolePermissions) {
700
663
  xw.startElement("RolePermission");
701
664
  xw.writeAttribute("Permissions", rolePermission.permissions.toString());
702
- xw.text(n(xw, rolePermission.roleId));
665
+ xw.text((0, nodeset_xml_primitives_js_1.n)(xw, rolePermission.roleId));
703
666
  xw.endElement();
704
667
  }
705
668
  xw.endElement();
@@ -710,25 +673,13 @@ function dumpCommonElements(xw, node) {
710
673
  _dumpReferences(xw, node);
711
674
  _dumpRolePermissions(xw, node);
712
675
  }
713
- function coerceInt64ToInt32(int64) {
714
- if (typeof int64 === "number") {
715
- return int64;
716
- }
717
- if (int64[0] === 0xffffffff && int64[1] === 0xffffffff) {
718
- return 0xffffffff;
719
- }
720
- if (int64[0] !== 0) {
721
- warningLog("coerceInt64ToInt32 , loosing high word in conversion");
722
- }
723
- return int64[1];
724
- }
725
676
  function _dumpEnumDefinition(xw, enumDefinition) {
726
677
  enumDefinition.fields = enumDefinition.fields || [];
727
678
  for (const defItem of enumDefinition.fields) {
728
679
  xw.startElement("Field");
729
680
  xw.writeAttribute("Name", defItem.name);
730
681
  if (!(0, node_opcua_utils_1.isNullOrUndefined)(defItem.value)) {
731
- xw.writeAttribute("Value", coerceInt64ToInt32(defItem.value));
682
+ xw.writeAttribute("Value", (0, nodeset_xml_primitives_js_1.coerceInt64ToInt32)(defItem.value));
732
683
  }
733
684
  _dumpDescription(xw, defItem);
734
685
  xw.endElement();
@@ -744,6 +695,11 @@ function _dumpStructureDefinition(xw, structureDefinition, baseStructureDefiniti
744
695
  // do not repeat elements that are already defined in base structure in the xml ouput!
745
696
  const fields = structureDefinition.fields || [];
746
697
  const nbFieldsInBase = baseStructureDefinition ? baseStructureDefinition.fields?.length || 0 : 0;
698
+ // Part 3 8.51: in a *WithSubtypedValues structure, isOptional is where "subtyping allowed" is
699
+ // held, and the document spells that AllowSubTypes. Written as IsOptional it said the opposite
700
+ // of what it meant, and the AllowSubTypes the document had was simply gone
701
+ const subtypedValues = structureDefinition.structureType === node_opcua_types_1.StructureType.StructureWithSubtypedValues ||
702
+ structureDefinition.structureType === node_opcua_types_1.StructureType.UnionWithSubtypedValues;
747
703
  for (let index = nbFieldsInBase; index < fields.length; index++) {
748
704
  const defItem = fields[index];
749
705
  xw.startElement("Field");
@@ -754,8 +710,8 @@ function _dumpStructureDefinition(xw, structureDefinition, baseStructureDefiniti
754
710
  if (defItem.valueRank !== undefined && defItem.valueRank !== -1) {
755
711
  xw.writeAttribute("ValueRank", defItem.valueRank);
756
712
  }
757
- if (defItem.isOptional /* && defItem.isOptional !== false */) {
758
- xw.writeAttribute("IsOptional", defItem.isOptional.toString());
713
+ if (defItem.isOptional) {
714
+ xw.writeAttribute(subtypedValues ? "AllowSubTypes" : "IsOptional", "true");
759
715
  }
760
716
  if (defItem.maxStringLength !== undefined && defItem.maxStringLength !== 0) {
761
717
  xw.writeAttribute("MaxStringLength", defItem.maxStringLength);
@@ -763,7 +719,7 @@ function _dumpStructureDefinition(xw, structureDefinition, baseStructureDefiniti
763
719
  // todo : SymbolicName ( see AutoId )
764
720
  if (defItem.dataType) {
765
721
  // todo : namespace translation !
766
- xw.writeAttribute("DataType", n(xw, defItem.dataType));
722
+ xw.writeAttribute("DataType", (0, nodeset_xml_primitives_js_1.n)(xw, defItem.dataType));
767
723
  }
768
724
  _dumpDescription(xw, defItem);
769
725
  xw.endElement();
@@ -771,9 +727,32 @@ function _dumpStructureDefinition(xw, structureDefinition, baseStructureDefiniti
771
727
  }
772
728
  function _dumpUADataTypeDefinition(xw, uaDataType) {
773
729
  const uaDataTypeBase = uaDataType.subtypeOfObj;
730
+ // an OptionSet first: node-opcua builds neither an enumeration nor a structure for one, so
731
+ // neither branch below would fire and the whole <Definition> would be dropped. The fields are
732
+ // the ones the loader kept, see UADataTypeImpl.isOptionSetDataType
733
+ const asImpl = uaDataType;
734
+ // what the document called this definition, or -- for a DataType built here, which never had a
735
+ // declaration -- the browse name, which is the only name available
736
+ const definitionName = asImpl.declaredDefinitionName ?? (0, nodeset_xml_primitives_js_1.b)(xw, uaDataType.browseName);
737
+ if (asImpl.isOptionSetDataType && asImpl.declaredDefinitionFields) {
738
+ xw.startElement("Definition");
739
+ xw.writeAttribute("Name", definitionName);
740
+ xw.writeAttribute("IsOptionSet", "true");
741
+ for (const field of asImpl.declaredDefinitionFields) {
742
+ xw.startElement("Field");
743
+ xw.writeAttribute("Name", field.name || "");
744
+ if (field.value !== undefined && field.value !== null) {
745
+ xw.writeAttribute("Value", field.value);
746
+ }
747
+ _dumpDescription(xw, field);
748
+ xw.endElement();
749
+ }
750
+ xw.endElement();
751
+ return;
752
+ }
774
753
  if (uaDataType.isEnumeration()) {
775
754
  xw.startElement("Definition");
776
- xw.writeAttribute("Name", b(xw, uaDataType.browseName));
755
+ xw.writeAttribute("Name", definitionName);
777
756
  _dumpEnumDefinition(xw, uaDataType.getEnumDefinition());
778
757
  xw.endElement();
779
758
  return;
@@ -785,9 +764,11 @@ function _dumpUADataTypeDefinition(xw, uaDataType) {
785
764
  const t = true;
786
765
  if (t || dataValue.statusCode.isGood()) {
787
766
  const definition = uaDataType.getStructureDefinition();
788
- const baseDefinition = uaDataTypeBase ? uaDataTypeBase.getStructureDefinition() : null;
767
+ // a structure's supertype need not be a structure: `Structure` itself subtypes BaseDataType,
768
+ // which has no definition at all. Asking it for one threw, and took the whole export with it
769
+ const baseDefinition = uaDataTypeBase?.isStructure() ? uaDataTypeBase.getStructureDefinition() : null;
789
770
  xw.startElement("Definition");
790
- xw.writeAttribute("Name", b(xw, uaDataType.browseName));
771
+ xw.writeAttribute("Name", definitionName);
791
772
  if (definition.structureType === node_opcua_types_1.StructureType.Union) {
792
773
  xw.writeAttribute("IsUnion", "true");
793
774
  }
@@ -800,16 +781,16 @@ function _dumpUADataTypeDefinition(xw, uaDataType) {
800
781
  function dumpUAView(xw, node) {
801
782
  _markAsVisited(xw, node);
802
783
  xw.startElement("UAView");
803
- xw.writeAttribute("NodeId", n(xw, node.nodeId));
804
- xw.writeAttribute("BrowseName", b(xw, node.browseName));
784
+ xw.writeAttribute("NodeId", (0, nodeset_xml_primitives_js_1.n)(xw, node.nodeId));
785
+ xw.writeAttribute("BrowseName", (0, nodeset_xml_primitives_js_1.b)(xw, node.browseName));
805
786
  dumpCommonElements(xw, node);
806
787
  xw.endElement();
807
788
  }
808
789
  function dumpUADataType(xw, node) {
809
790
  _markAsVisited(xw, node);
810
791
  xw.startElement("UADataType");
811
- xw.writeAttribute("NodeId", n(xw, node.nodeId));
812
- xw.writeAttribute("BrowseName", b(xw, node.browseName));
792
+ xw.writeAttribute("NodeId", (0, nodeset_xml_primitives_js_1.n)(xw, node.nodeId));
793
+ xw.writeAttribute("BrowseName", (0, nodeset_xml_primitives_js_1.b)(xw, node.browseName));
813
794
  if (node.symbolicName !== node.browseName.name) {
814
795
  xw.writeAttribute("SymbolicName", node.symbolicName);
815
796
  }
@@ -845,15 +826,21 @@ function dumpUAVariable(xw, node) {
845
826
  if (dataTypeNode) {
846
827
  // verify that data Type is in alias
847
828
  // xx const dataTypeName = dataTypeNode.browseName.toString();
848
- const dataTypeName = b(xw, resolveDataTypeName(addressSpace, dataTypeNode.nodeId));
829
+ const dataTypeName = (0, nodeset_xml_primitives_js_1.b)(xw, resolveDataTypeName(addressSpace, dataTypeNode.nodeId));
849
830
  xw.writeAttribute("DataType", dataTypeName);
850
831
  }
851
832
  }
852
833
  {
853
834
  // sub elements
854
835
  dumpCommonElements(xw, node);
855
- const value = node.$dataValue.value;
856
- if (value) {
836
+ // a value the loader made up for a variable the document left unvalued is not written
837
+ // back out; see valueWasSynthesized in nodeset_record_applier. What used to stand here was
838
+ // _isDefaultValue, which dropped every zero and every empty string alike -- suppressing the
839
+ // made-up ones at the cost of the ones the document really did declare
840
+ const synthesized = node.valueWasSynthesized;
841
+ const dataValue = node.$dataValue;
842
+ const value = dataValue.value;
843
+ if (value && !synthesized && !dataValue.statusCode.equals(node_opcua_status_code_1.StatusCodes.BadWaitingForInitialData)) {
857
844
  _dumpValue(xw, node, value);
858
845
  }
859
846
  }
@@ -885,7 +872,7 @@ function dumpUAVariableType(xw, node) {
885
872
  node.nodeId.toString());
886
873
  }
887
874
  else {
888
- const dataTypeName = b(xw, resolveDataTypeName(addressSpace, dataTypeNode.nodeId));
875
+ const dataTypeName = (0, nodeset_xml_primitives_js_1.b)(xw, resolveDataTypeName(addressSpace, dataTypeNode.nodeId));
889
876
  xw.writeAttribute("DataType", dataTypeName);
890
877
  }
891
878
  }
@@ -928,7 +915,7 @@ function dumpUAMethod(xw, node) {
928
915
  xw.startElement("UAMethod");
929
916
  dumpCommonAttributes(xw, node);
930
917
  if (node.methodDeclarationId) {
931
- xw.writeAttribute("MethodDeclarationId", n(xw, node.methodDeclarationId));
918
+ xw.writeAttribute("MethodDeclarationId", (0, nodeset_xml_primitives_js_1.n)(xw, node.methodDeclarationId));
932
919
  }
933
920
  dumpCommonElements(xw, node);
934
921
  xw.endElement();
@@ -1056,9 +1043,6 @@ base_node_impl_js_1.BaseNodeImpl.prototype.dumpXML = function (xw) {
1056
1043
  xw.translationTable = xw.translationTable || translationTable;
1057
1044
  writeWalkEvents(xw, this.addressSpace, translationTable, events);
1058
1045
  };
1059
- function makeTypeXsd(namespaceUri) {
1060
- return `${namespaceUri.replace(/\/$/, "")}/Type.xsd`;
1061
- }
1062
1046
  namespace_impl_js_1.NamespaceImpl.prototype.toNodeset2XML = function () {
1063
1047
  const namespaceArrayNode = this.addressSpace.findNode(node_opcua_constants_1.VariableIds.Server_NamespaceArray);
1064
1048
  const namespaceArray = namespaceArrayNode
@@ -1091,10 +1075,10 @@ namespace_impl_js_1.NamespaceImpl.prototype.toNodeset2XML = function () {
1091
1075
  }
1092
1076
  const translatedIndex = translationTable.get(namespace.index);
1093
1077
  const smallName = `ns${translatedIndex}`;
1094
- xw.writeAttribute(`xmlns:${smallName}`, makeTypeXsd(namespace.namespaceUri));
1078
+ xw.writeAttribute(`xmlns:${smallName}`, (0, nodeset_xml_primitives_js_1.makeTypeXsd)(namespace.namespaceUri));
1095
1079
  namespacesMap[namespace.namespaceUri] = smallName;
1096
1080
  }
1097
- initXmlWriterEx(xw, namespacesMap, namespaceArray);
1081
+ (0, nodeset_xml_primitives_js_1.initXmlWriterEx)(xw, namespacesMap, namespaceArray);
1098
1082
  xw.startElement("NamespaceUris");
1099
1083
  for (const namespaceUri of header.namespaceUris) {
1100
1084
  xw.startElement("Uri");