Commit 605874c7 authored by Jeno Attila Balasko's avatar Jeno Attila Balasko Committed by Gerrit Code Review
Browse files

Merge "XER: Now can decode attributes to untagged unions (Bug 521798)"

parents 4000b96e 50a00f09
......@@ -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();
}
......
......@@ -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.
{
......
......@@ -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) {
......
......@@ -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());
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment