diff --git a/unittest/share/test_xml_bin.cpp b/unittest/share/test_xml_bin.cpp
index 784c677fbb..ced28237f9 100644
--- a/unittest/share/test_xml_bin.cpp
+++ b/unittest/share/test_xml_bin.cpp
@@ -1436,7 +1436,12 @@ TEST_F(TestXmlBin, test_print_ns)
{
int ret = 0;
ObCollationType type = CS_TYPE_UTF8MB4_GENERAL_CI;
- common::ObString xml_text("test");
+ common::ObString xml_text(
+ ""
+ ""
+ "test"
+ ""
+ "");
ObArenaAllocator allocator(ObModIds::TEST);
ObXmlDocument* doc = nullptr;
@@ -1447,7 +1452,9 @@ TEST_F(TestXmlBin, test_print_ns)
ObStringBuffer buf_str(&allocator);
ObXmlBin bin(ctx);
- doc->print_document(buf_str, type, ObXmlFormatType::NO_FORMAT);
+ ret = doc->print_document(buf_str, type, ObXmlFormatType::NO_FORMAT);
+ ASSERT_EQ(ret, 0);
+
ObStringBuffer buf_str_bin(&allocator);
ASSERT_EQ(bin.parse_tree(doc), 0);
@@ -1624,6 +1631,36 @@ TEST_F(TestXmlBin, read_by_key)
}
+TEST_F(TestXmlBin, print_empty_element)
+{
+ int ret = 0;
+ ObCollationType type = CS_TYPE_UTF8MB4_GENERAL_CI;
+ common::ObString xml_text(
+ "<>>"
+ );
+
+ ObArenaAllocator allocator(ObModIds::TEST);
+
+ ObMulModeMemCtx* ctx = nullptr;
+ ASSERT_EQ(ObXmlUtil::create_mulmode_tree_context(&allocator, ctx), OB_SUCCESS);
+ ObXmlDocument root(M_UNPARSED, ctx);
+ ObXmlElement child1(M_UNPARSED, ctx);
+
+ ASSERT_EQ(root.add_element(&child1), 0);
+ ObXmlDocument* doc = &root;
+
+ {
+ ObXmlBin xbin(ctx);
+ ObArray result1;
+ ASSERT_EQ(xbin.parse_tree(doc), 0);
+ ASSERT_EQ(xbin.set_child_at(0), 0);
+
+ ObStringBuffer buf_str_bin(&allocator);
+ ASSERT_EQ(xbin.print_xml(buf_str_bin, 0, 0 ,0), 0);
+ cout << buf_str_bin.ptr() << endl;
+ }
+}
+
} // common
} // oceanbase
diff --git a/unittest/share/test_xml_tree_base.cpp b/unittest/share/test_xml_tree_base.cpp
index 2f0102721c..2ad5951204 100644
--- a/unittest/share/test_xml_tree_base.cpp
+++ b/unittest/share/test_xml_tree_base.cpp
@@ -130,7 +130,7 @@ public:
ObString get_prefix() { return ObString(); }
ObString get_encoding() { return ObString(); }
uint16_t get_standalone() { return 0; }
- ObIMulModeBase* attribute_at(int64_t pos) { return nullptr; }
+ ObIMulModeBase* attribute_at(int64_t pos, ObIMulModeBase* buffer = nullptr) { return nullptr; }
bool has_flags(ObMulModeNodeFlag flag) { return false; }
bool get_unparse() { return false; }
bool get_is_empty() { return false; }
@@ -218,7 +218,7 @@ public:
return ret;
}
- virtual ObIMulModeBase* at(int64_t pos)
+ virtual ObIMulModeBase* at(int64_t pos, ObIMulModeBase* buffer = nullptr)
{
ObLibTreeNodeBase* tmp = ObLibContainerNode::member(pos);
TXmlNodeBase* res = nullptr;