1 /******************************************************************************
2 * Copyright (c) 2000-2015 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 ******************************************************************************/
9 modulepar boolean UseType_verbose := false;
10 #define verbose UseType_verbose
11 #include "../macros.ttcnin"
13 type component Shop {}
21 type record Trousers {
27 variant (available) "attribute"
36 variant (available) "attribute"
39 type union ProductUT {
47 variant "namespace as 'http://www.example.com' prefix 'exm'"
50 DECLARE_XER_ENCODERS(ProductUT, prodUT);
51 DECLARE_EXER_ENCODERS(ProductUT, prodUT);
53 const ProductUT shoo := { shoes := { available := false, color := "brown", size := 42 } }
55 const universal charstring str_shoo_e :=
56 "<exm:ProductUT xmlns:exm=\'http://www.example.com\' " &
57 "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type=\'shoes\' available='false'>\n" &
58 "\t<color>brown</color>\n" &
59 "\t<size>42</size>\n" &
60 "</exm:ProductUT>\n" &
63 const universal charstring str_shoo_b :=
66 "\t\t<available><false/></available>\n" &
67 "\t\t<color>brown</color>\n" &
68 "\t\t<size>42</size>\n" &
73 testcase enc_ut() runs on Shop {
74 CHECK_METHOD(bxer_enc_prodUT, shoo, str_shoo_b);
75 CHECK_METHOD(exer_enc_prodUT, shoo, str_shoo_e);
78 testcase dec_ut() runs on Shop
80 CHECK_DECODE(bxer_dec_prodUT, str_shoo_b, ProductUT, shoo);
81 CHECK_DECODE(exer_dec_prodUT, str_shoo_e, ProductUT, shoo);
84 /* * * An escapee from Name * * */
92 variant (first) "name as 'One'";
93 variant (second) "name as 'Two'";
96 DECLARE_XER_ENCODERS(U, u);
97 DECLARE_EXER_ENCODERS(U, u);
99 const U v := { second := 123 }
101 const universal charstring str_12_e :=
102 "<U xmlns:xsi=\'http://www.w3.org/2001/XMLSchema-instance\' xsi:type=\'Two\'>123</U>\n\n";
104 const universal charstring str_12_b :=
106 "\t<second>123</second>\n" &
111 testcase encode_12() runs on Shop
113 CHECK_METHOD(bxer_enc_u, v, str_12_b);
114 CHECK_METHOD(exer_enc_u, v, str_12_e);
117 testcase decode_12() runs on Shop
119 CHECK_DECODE(bxer_dec_u, str_12_b, U, v);
120 CHECK_DECODE(exer_dec_u, str_12_e, U, v);
127 execute(encode_12());
128 execute(decode_12());
134 variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"