diff --git a/core/Boolean.cc b/core/Boolean.cc index a606b3d635245fa32853578a8f4e2788deb22002..60e788f1179d3deb99ed1dacead221cd27edff49 100644 --- a/core/Boolean.cc +++ b/core/Boolean.cc @@ -687,7 +687,7 @@ int BOOLEAN::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader, TTCN_EncDec::ET_INVAL_MSG, "Boolean must be empty element"); value = (const char*)reader.LocalName(); } - else if (XML_READER_TYPE_TEXT == type) { + else if (XML_READER_TYPE_TEXT == type || XML_READER_TYPE_ATTRIBUTE == type) { // TextBoolean value = (const char*)reader.Value(); } diff --git a/core/Charstring.cc b/core/Charstring.cc index 6db29704ecec8fb0faf7683e23c13830c37275bd..4dfd526d388fc6dd3d1976085563079c85b4c643 100644 --- a/core/Charstring.cc +++ b/core/Charstring.cc @@ -1378,7 +1378,7 @@ unsigned int xlate(cbyte*in, int phase, unsigned char*dest) { int CHARSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader, unsigned int flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*) { int exer = is_exer(flavor); - + if (exer && (p_td.xer_bits & XER_ATTRIBUTE)) { const char * name = verify_name(reader, p_td, exer); (void)name; @@ -1413,7 +1413,7 @@ int CHARSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader, depth = reader.Depth(); } else if ((depth != -1 || omit_tag) - && (XML_READER_TYPE_TEXT == type || XML_READER_TYPE_CDATA == type)) + && (XML_READER_TYPE_TEXT == type || XML_READER_TYPE_CDATA == type || (omit_tag && XML_READER_TYPE_ATTRIBUTE))) // Process #text node if we already processed the element node, or // there is no element node because UNTAGGED is in effect. { diff --git a/core/Universal_charstring.cc b/core/Universal_charstring.cc index 92b29cd5df8fc9e7102a2ea3246a7516e78a79e1..3bb4fb6c1d78a983bde3b25034c6e23ff57e2af3 100644 --- a/core/Universal_charstring.cc +++ b/core/Universal_charstring.cc @@ -2244,7 +2244,18 @@ int UNIVERSAL_CHARSTRING::XER_decode(const XERdescriptor_t& p_td, "Invalid escape sequence '<%s/>'", name); } break; } - + + case XML_READER_TYPE_ATTRIBUTE: { + if (omit_tag) { + const char * text = (const char*)reader.Value(); + int len = strlen(text); + accumulator.put_s(len, (cbyte*)text); + decode_utf8(accumulator.get_len(), accumulator.get_data()); + goto fini; + } + break; + } + case XML_READER_TYPE_END_ELEMENT: { decode_utf8(accumulator.get_len(), accumulator.get_data()); if (!omit_tag) { diff --git a/regression_test/XML/EXER-whitepaper/Attribute.ttcnpp b/regression_test/XML/EXER-whitepaper/Attribute.ttcnpp index bddf60745c32f2ad6ed4328a8cb757996990cf0b..cda16fc1be9c709a00d706a17eeed8b4494b3252 100644 --- a/regression_test/XML/EXER-whitepaper/Attribute.ttcnpp +++ b/regression_test/XML/EXER-whitepaper/Attribute.ttcnpp @@ -426,6 +426,151 @@ testcase dec_atr_schemaloc() runs on ATR } +group UnionAttribute { + +type record MyRecord { + IntegerUnion iu, + CharstringUnion cu, + UniversalCharstringUnion ucu, + BooleanUnion bu, + FloatUnion fu, + BitstringUnion bsu, + OctetstringUnion ou, + HexStringUnion hu, + VerdictTypeUnion vu, + + integer i + +} with { + variant (iu) "attribute"; + variant (cu) "attribute"; + variant (ucu) "attribute"; + variant (bu) "attribute"; + variant (fu) "attribute"; + variant (bsu) "attribute"; + variant (ou) "attribute"; + variant (hu) "attribute"; + variant (vu) "attribute"; +} + +type union IntegerUnion { + integer i +} +with { + variant "useUnion"; +variant "attribute"; +} + +type union CharstringUnion { + charstring cs +} +with { + variant "useUnion"; +variant "attribute"; +} + +type union UniversalCharstringUnion { + universal charstring uc +} +with { + variant "useUnion"; + variant "attribute"; +} + +type union BooleanUnion { + boolean b +} +with { + variant "useUnion"; + variant "attribute"; +} + +type union FloatUnion { + float f +} +with { + variant "useUnion"; + variant "attribute"; +} + +type union BitstringUnion { + bitstring b +} +with { + variant "useUnion"; + variant "attribute"; +} + +type union OctetstringUnion { + octetstring o +} +with { + variant "useUnion"; + variant "attribute"; +} + +type union HexStringUnion { + hexstring h +} +with { + variant "useUnion"; + variant "attribute"; +} + +type union VerdictTypeUnion { + verdicttype v +} +with { + variant "useUnion"; + variant "attribute"; +} + +const MyRecord c_union_attr := { + iu := { i := 42 }, + cu := { cs := "charstring" }, + ucu := { uc := "universal charstring"}, + bu := { b := false }, + fu := { f := 3.14 }, + bsu := { b := '010010'B }, + ou := { o := 'DEAD00BEEF'O }, + hu := { h := 'DEAD00BEEF'H }, + vu := { v := inconc }, + i := 42 + }; + +const universal charstring c_union_attr_str := +"<MyRecord xmlns:a='http://www.somewhere.com' "& +"a:iu='42' "& +"a:cu='charstring' "& +"a:ucu='universal charstring' "& +"a:bu='false' "& +"a:fu='3.140000' "& +"a:bsu='010010' "& +"a:ou='DEAD00BEEF' "& +"a:hu='DEAD00BEEF' "& +"a:vu='inconc'>\n"& +"\t<i>42</i>\n"& +"</MyRecord>\n\n"; + +DECLARE_EXER_ENCODERS(MyRecord, m_rec); + +testcase enc_attr_union() runs on ATR +{ + CHECK_METHOD(exer_enc_m_rec, c_union_attr, c_union_attr_str); +} + +testcase dec_attr_union() runs on ATR +{ + CHECK_DECODE(exer_dec_m_rec, c_union_attr_str, MyRecord, c_union_attr); +} + +} with { + variant "namespace as 'http://www.somewhere.com' prefix 'a'"; + variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} + + + control { execute(enc_atr()); execute(dec_atr()); @@ -436,6 +581,9 @@ control { execute(hl19919(), 5.0); // too bad the timer can't save the testcase from its endless loop execute(dec_atr_schemaloc()); + + execute(enc_attr_union()); + execute(dec_attr_union()); } }