Skip to content

Commit

Permalink
fix: LocalizedText to xml now ignores empty Locales
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Feb 6, 2022
1 parent 310be93 commit 64b82e9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ function _dumpReferences(xw: XmlWriter, node: BaseNode) {
xw.endElement();
}
function _dumpLocalizedText(xw: XmlWriter, v: LocalizedText) {
xw.startElement("Locale");
if (v.locale) {
if (v.locale && v.locale.length) {
xw.startElement("Locale");
xw.text(v.locale);
xw.endElement();
}
xw.endElement();
xw.startElement("Text");
if (v.text) {
xw.text(v.text);
Expand Down Expand Up @@ -802,7 +802,7 @@ function _dumpUADataTypeDefinition(xw: XmlWriter, uaDataType: UADataType) {
const definition = uaDataType.getStructureDefinition();
const baseDefinition = uaDataTypeBase ? uaDataTypeBase.getStructureDefinition() : null;
xw.startElement("Definition");
xw.writeAttribute("Name", uaDataType.browseName.name!);
xw.writeAttribute("Name", b(xw,uaDataType.browseName));
if (definition.structureType === StructureType.Union) {
xw.writeAttribute("IsUnion", "true");
}
Expand Down
5 changes: 0 additions & 5 deletions packages/node-opcua-address-space/test/test_load_nodeset2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,23 +336,18 @@ describe("testing NodeSet XML file loading", function (this: any) {
<Value>
<ListOfLocalizedText xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
<LocalizedText>
<Locale/>
<Text>NORMAL</Text>
</LocalizedText>
<LocalizedText>
<Locale/>
<Text>FAILURE</Text>
</LocalizedText>
<LocalizedText>
<Locale/>
<Text>CHECK_FUNCTION</Text>
</LocalizedText>
<LocalizedText>
<Locale/>
<Text>OFF_SPEC</Text>
</LocalizedText>
<LocalizedText>
<Locale/>
<Text>MAINTENANCE_REQUIRED</Text>
</LocalizedText>
</ListOfLocalizedText>
Expand Down
2 changes: 0 additions & 2 deletions packages/node-opcua-address-space/test/test_nodeset_to_xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ describe("testing nodeset to xml", () => {
<ValueRank>-1</ValueRank>
<ArrayDimensions></ArrayDimensions>
<Description>
<Locale/>
<Text>specifies the number of seconds to wait before the picture is taken </Text>
</Description>
</Argument>
Expand Down Expand Up @@ -302,7 +301,6 @@ describe("testing nodeset to xml", () => {
<ValueRank>-1</ValueRank>
<ArrayDimensions></ArrayDimensions>
<Description>
<Locale/>
<Text>the generated image</Text>
</Description>
</Argument>
Expand Down

0 comments on commit 64b82e9

Please sign in to comment.