diff --git a/core/Universal_charstring.cc b/core/Universal_charstring.cc index b80efdc390b06d3aeed345f34efc0194b01484a3..65219579827687882ea2d13970b57b2fe01c21da 100644 --- a/core/Universal_charstring.cc +++ b/core/Universal_charstring.cc @@ -1888,6 +1888,7 @@ int UNIVERSAL_CHARSTRING::XER_encode(const XERdescriptor_t& p_td, XmlReaderWrap checker(other_buf); // Walk through the XML. If it's not well-formed, XmlReaderWrap // will call TTCN_error => Dynamic testcase error. + bool top_element_checked = false; while (1 == checker.Read()) { if (checker.NodeType() == XML_READER_TYPE_ELEMENT && (p_td.xer_bits & (ANY_FROM | ANY_EXCEPT))) { @@ -1912,9 +1913,11 @@ int UNIVERSAL_CHARSTRING::XER_encode(const XERdescriptor_t& p_td, other_buf.set_pos(index); new_buf.put_s(other_buf.get_len() - index, other_buf.get_read_data()); other_buf = new_buf; - } else { + } else if (!top_element_checked) { + // the namespace restrictions only apply to the top-level element check_namespace_restrictions(p_td, xmlns); } + top_element_checked = true; } } diff --git a/regression_test/XML/EXER-whitepaper/AnyElement.ttcnpp b/regression_test/XML/EXER-whitepaper/AnyElement.ttcnpp index a9212fe45bd78d7f7a019d16a45f5823158f7a75..7c40f1e7424f73dca2eb240a48b39683b5ce9905 100644 --- a/regression_test/XML/EXER-whitepaper/AnyElement.ttcnpp +++ b/regression_test/XML/EXER-whitepaper/AnyElement.ttcnpp @@ -404,6 +404,37 @@ testcase decode_aes() runs on AE CHECK_DECODE(exer_dec_aes, str_aes_e, AEProductSingle, aesp_e); } + +const AEProduct aep_emb := { + name := "nothing", + price := 1, + info := "<ns:top xmlns:ns=\"http://www.example.com/A\">" & + "<ns1:sub1 xmlns:ns1=\"http://www.example.com/C\">100</ns1:sub1>" & + "<ns2:sub2 xmlns:ns2=\"http://www.somewhereelse.com\">200</ns2:sub2>" & + "</ns:top>" +} + +const universal charstring str_ae_emb := +"<AEProduct>\n" & +"\t<name>nothing</name>\n" & +"\t<price>1</price>\n" & +"\t<ns:top xmlns:ns=\"http://www.example.com/A\">" & + "<ns1:sub1 xmlns:ns1=\"http://www.example.com/C\">100</ns1:sub1>" & + "<ns2:sub2 xmlns:ns2=\"http://www.somewhereelse.com\">200</ns2:sub2>" & + "</ns:top>\n" & +"</AEProduct>\n\n"; + +testcase encode_ae_emb() runs on AE +{ + CHECK_METHOD(exer_enc_ae, aep_emb, str_ae_emb); +} + +testcase decode_ae_emb() runs on AE +{ + CHECK_DECODE(exer_dec_ae, str_ae_emb, AEProduct, aep_emb); +} + + control { execute(encode_ae()) @@ -423,6 +454,9 @@ control execute(encode_aes()) execute(decode_aes()) + + execute(encode_ae_emb()) + execute(decode_ae_emb()) } }