Skip to content

Commit

Permalink
Merge branch 'main' into should_set_device_uuid_when_specified_in_ada…
Browse files Browse the repository at this point in the history
…pter_config
  • Loading branch information
wsobel committed Jan 24, 2024
2 parents 3c04818 + 595c0e0 commit f4e4a80
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(AGENT_VERSION_MAJOR 2)
set(AGENT_VERSION_MINOR 2)
set(AGENT_VERSION_PATCH 0)
set(AGENT_VERSION_BUILD 16)
set(AGENT_VERSION_BUILD 17)
set(AGENT_VERSION_RC "")

# This minimum version is to support Visual Studio 2019 and C++ feature checking and FetchContent
Expand Down
9 changes: 6 additions & 3 deletions src/mtconnect/entity/xml_printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,21 @@ namespace mtconnect {
if (p.first == "VALUE")
{
// The value is the content for a simple element
THROW_IF_XML2_ERROR(xmlTextWriterWriteString(writer, BAD_CAST s));
if (*s != '\0')
THROW_IF_XML2_ERROR(xmlTextWriterWriteString(writer, BAD_CAST s));
}
else if (p.first == "RAW")
{
THROW_IF_XML2_ERROR(xmlTextWriterWriteRaw(writer, BAD_CAST s));
if (*s != '\0')
THROW_IF_XML2_ERROR(xmlTextWriterWriteRaw(writer, BAD_CAST s));
}
else
{
QName name(p.first);
string qname = stripUndeclaredNamespace(name, namespaces);
AutoElement element(writer, qname);
THROW_IF_XML2_ERROR(xmlTextWriterWriteString(writer, BAD_CAST s));
if (*s != '\0')
THROW_IF_XML2_ERROR(xmlTextWriterWriteString(writer, BAD_CAST s));
}
}

Expand Down
6 changes: 3 additions & 3 deletions styles/styles.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:m="urn:mtconnect.org:MTConnectDevices:2.0"
xmlns:s="urn:mtconnect.org:MTConnectStreams:2.0"
xmlns:e="urn:mtconnect.org:MTConnectError:2.0"
xmlns:m="urn:mtconnect.org:MTConnectDevices:2.2"
xmlns:s="urn:mtconnect.org:MTConnectStreams:2.2"
xmlns:e="urn:mtconnect.org:MTConnectError:2.2"
xmlns:js="urn:custom-javascript"
exclude-result-prefixes="msxsl js"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
Expand Down
22 changes: 22 additions & 0 deletions test_package/agent_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3000,3 +3000,25 @@ TEST_F(AgentTest, device_should_have_hash_for_2_2)
ASSERT_XML_PATH_EQUAL(doc, "//m:DeviceAdded[3]@hash", (*di)->get<string>("hash").c_str());
}
}

TEST_F(AgentTest, should_not_add_spaces_to_output)
{
addAdapter();

m_agentTestHelper->m_adapter->processData("2024-01-22T20:00:00Z|program|");
m_agentTestHelper->m_adapter->processData("2024-01-22T20:00:00Z|block|");

{
PARSE_XML_RESPONSE("/current");
ASSERT_XML_PATH_EQUAL(doc, "//m:DeviceStream//m:Program", "");
ASSERT_XML_PATH_EQUAL(doc, "//m:DeviceStream//m:Block", "");
}

m_agentTestHelper->m_adapter->processData("2024-01-22T20:00:00Z|program| |block| ");

{
PARSE_XML_RESPONSE("/current");
ASSERT_XML_PATH_EQUAL(doc, "//m:DeviceStream//m:Program", "");
ASSERT_XML_PATH_EQUAL(doc, "//m:DeviceStream//m:Block", "");
}
}

0 comments on commit f4e4a80

Please sign in to comment.