From ebf1ace0b60f1be579364e1ebafdbaebeb222bc0 Mon Sep 17 00:00:00 2001
From: Botond Baranyi <botond.baranyi@ericsson.com>
Date: Thu, 17 Sep 2020 18:24:05 +0200
Subject: [PATCH] Updated xsd2ttcn to generate the '@default' modifier for
 element and type substitutions (bug 564920)

Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
Change-Id: I70335e24c8611c42bd5dfa0dc7e994cde8a4efda
---
 .../XmlTest_expectedTtcns/XSD_Definitions_e.ttcn         | 2 +-
 .../www_example_org_elements_e.ttcn                      | 2 +-
 .../www_example_org_generate_element_substitution_e.ttcn | 2 +-
 .../www_example_org_only_element_substitution_e.ttcn     | 2 +-
 ...example_org_substitutiongroup_abstract_block_1_e.ttcn | 2 +-
 ...example_org_substitutiongroup_abstract_block_2_e.ttcn | 2 +-
 ..._org_substitutiongroup_complex_without_element_e.ttcn | 2 +-
 ...xample_org_substitutiongroup_complextype_block_e.ttcn | 2 +-
 .../www_example_org_substitutiongroup_e.ttcn             | 2 +-
 .../www_example_org_substitutiongroup_main_e.ttcn        | 2 +-
 .../www_example_org_substitutiongroup_name_as_e.ttcn     | 2 +-
 .../www_example_org_substitutiongroup_rename_e.ttcn      | 2 +-
 .../www_example_org_type_subs_with_elem_subs_e.ttcn      | 4 ++--
 ...w_example_org_type_substitution_abstract_block_e.ttcn | 6 +++---
 .../www_example_org_type_substitution_builtintype_e.ttcn | 2 +-
 .../www_example_org_type_substitution_chain_e.ttcn       | 4 ++--
 ..._example_org_type_substitution_complex_cascade_e.ttcn | 6 +++---
 .../www_example_org_type_substitution_e.ttcn             | 2 +-
 ..._example_org_type_substitution_elem_in_ct_mod1_e.ttcn | 8 ++++----
 .../www_example_org_type_substitution_mod1_e.ttcn        | 4 ++--
 .../www_example_org_type_substitution_mod2_e.ttcn        | 2 +-
 .../www_example_org_type_substitution_rename_e.ttcn      | 2 +-
 ...w_example_org_type_substitution_simple_cascade_e.ttcn | 8 ++++----
 .../www_example_org_type_substitution_simpletype_e.ttcn  | 8 ++++----
 xsdconvert/ComplexType.cc                                | 9 ++++++++-
 25 files changed, 48 insertions(+), 41 deletions(-)

diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/XSD_Definitions_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/XSD_Definitions_e.ttcn
index c8c954ad6..48630236f 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/XSD_Definitions_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/XSD_Definitions_e.ttcn
@@ -62,7 +62,7 @@ with {
 
 type union Head_group
 {
-	HeadType head,
+	@default HeadType head,
 	Extended extended
 }
 with {
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_elements_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_elements_e.ttcn
index cc556b6ff..0ff97600b 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_elements_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_elements_e.ttcn
@@ -157,7 +157,7 @@ with {
 
 type union Comment_group
 {
-	XSD.String comment,
+	@default XSD.String comment,
 	CustomerComment customerComment,
 	ShipComment shipComment
 }
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_generate_element_substitution_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_generate_element_substitution_e.ttcn
index a0d4df145..23dd7a09c 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_generate_element_substitution_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_generate_element_substitution_e.ttcn
@@ -96,7 +96,7 @@ with {
 
 type union Head_group
 {
-	XSD.String head,
+	@default XSD.String head,
 	Member2 member2
 }
 with {
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_only_element_substitution_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_only_element_substitution_e.ttcn
index 951f84047..b3cfe5b83 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_only_element_substitution_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_only_element_substitution_e.ttcn
@@ -96,7 +96,7 @@ with {
 
 type union RequestAbstractType1_group
 {
-	RequestAbstractType requestAbstractType1,
+	@default RequestAbstractType requestAbstractType1,
 	ProductionRequest productionRequest,
 	ProgrammingRequest programmingRequest
 }
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_1_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_1_e.ttcn
index 21409238b..585714d2b 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_1_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_1_e.ttcn
@@ -119,7 +119,7 @@ with {
 
 type union Head_group
 {
-	XSD.String head,
+	@default XSD.String head,
 	Member1 member1,
 	Member2 member2,
 	Member3 member3
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_2_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_2_e.ttcn
index 14fccdeac..22917d365 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_2_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_2_e.ttcn
@@ -119,7 +119,7 @@ with {
 
 type union Head_group
 {
-	XSD.String head,
+	@default XSD.String head,
 	Member1 member1,
 	Member2 member2,
 	Member3 member3
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complex_without_element_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complex_without_element_e.ttcn
index 8a51f3be6..d3a077f7c 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complex_without_element_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complex_without_element_e.ttcn
@@ -118,7 +118,7 @@ with {
 
 type union Head_group_1
 {
-	Head_type head,
+	@default Head_type head,
 	Member member,
 	Member2 member2,
 	StringEnum stringEnum
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complextype_block_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complextype_block_e.ttcn
index 5e32728ca..ae72b4ee3 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complextype_block_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complextype_block_e.ttcn
@@ -81,7 +81,7 @@ with {
 
 type union Head_group
 {
-	RestrictedType head,
+	@default RestrictedType head,
 	RestrictedTypeElem restrictedTypeElem
 }
 with {
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_e.ttcn
index 6ab38866f..ee8e10f52 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_e.ttcn
@@ -129,7 +129,7 @@ with {
 
 type union Head_group
 {
-	XSD.String head,
+	@default XSD.String head,
 	Member1 member1,
 	Member2 member2,
 	Member3 member3
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_main_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_main_e.ttcn
index 9f8ff80b6..75124af4f 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_main_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_main_e.ttcn
@@ -58,7 +58,7 @@ with {
 
 type union Subsgroup_group
 {
-	XSD.String subsgroup,
+	@default XSD.String subsgroup,
 	Replace replace_
 }
 with {
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_name_as_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_name_as_e.ttcn
index c1270211b..26e9e8c9b 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_name_as_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_name_as_e.ttcn
@@ -113,7 +113,7 @@ with {
 
 type union Head_group
 {
-	XSD.String head,
+	@default XSD.String head,
 	Member1 member1,
 	Member2 member2,
 	Member3 member3
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_rename_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_rename_e.ttcn
index ac151746a..34992f93a 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_rename_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_rename_e.ttcn
@@ -86,7 +86,7 @@ with {
 
 type union BaseElement_group
 {
-	BaseElement_1 baseElement,
+	@default BaseElement_1 baseElement,
 	Case_1 case_
 }
 with {
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_subs_with_elem_subs_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_subs_with_elem_subs_e.ttcn
index 85b43d0cf..8903eaa8c 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_subs_with_elem_subs_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_subs_with_elem_subs_e.ttcn
@@ -125,7 +125,7 @@ with {
 
 type union Request_group
 {
-	RequestAbstractType_derivations request,
+	@default RequestAbstractType_derivations request,
 	ProductionRequest productionRequest,
 	ProgrammingRequest programmingRequest
 }
@@ -138,7 +138,7 @@ with {
 
 type union RequestAbstractType_derivations
 {
-	RequestAbstractType requestAbstractType,
+	@default RequestAbstractType requestAbstractType,
 	MyProductionRequestType myProductionRequestType,
 	MyProgrammingRequestType myProgrammingRequestType
 }
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_abstract_block_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_abstract_block_e.ttcn
index 1f5116507..751957f9e 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_abstract_block_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_abstract_block_e.ttcn
@@ -170,7 +170,7 @@ with {
 
 type union ParentType_derivations
 {
-	ParentType parentType,
+	@default ParentType parentType,
 	ExtendedType extendedType,
 	RestrictedExtendedType restrictedExtendedType,
 	RestrictedType restrictedType,
@@ -189,7 +189,7 @@ with {
 
 type union RestrictedType_derivations
 {
-	RestrictedType restrictedType,
+	@default RestrictedType restrictedType,
 	RestrictedType2 restrictedType2,
 	RestrictedType2_1 restrictedType2_1,
 	RestrictedType3 restrictedType3
@@ -202,7 +202,7 @@ with {
 
 type union ExtendedType_derivations
 {
-	ExtendedType extendedType,
+	@default ExtendedType extendedType,
 	RestrictedExtendedType restrictedExtendedType
 }
 with {
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_builtintype_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_builtintype_e.ttcn
index a923e4c85..9d0f2eca3 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_builtintype_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_builtintype_e.ttcn
@@ -89,7 +89,7 @@ with {
 
 type union String_derivations
 {
-	XSD.String string,
+	@default XSD.String string,
 	Data data,
 	Enable enable,
 	Res res,
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_chain_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_chain_e.ttcn
index b6b8f174f..e09cfffaa 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_chain_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_chain_e.ttcn
@@ -136,7 +136,7 @@ with {
 
 type union ParentType_derivations
 {
-	ParentType parentType,
+	@default ParentType parentType,
 	RestrictedType restrictedType,
 	RestrictedType2 restrictedType2,
 	RestrictedType2_1 restrictedType2_1,
@@ -151,7 +151,7 @@ with {
 
 type union RestrictedType_derivations
 {
-	RestrictedType restrictedType,
+	@default RestrictedType restrictedType,
 	RestrictedType2 restrictedType2,
 	RestrictedType2_1 restrictedType2_1,
 	RestrictedType3 restrictedType3
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_complex_cascade_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_complex_cascade_e.ttcn
index 7cc7a0eee..6e9f62528 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_complex_cascade_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_complex_cascade_e.ttcn
@@ -147,7 +147,7 @@ with {
 
 type union RequestType_derivations
 {
-	RequestType requestType,
+	@default RequestType requestType,
 	MyProductionRequestType_1 myProductionRequestType,
 	MyProductionRequestType2_1 myProductionRequestType2,
 	MyProductionRequestType3 myProductionRequestType3,
@@ -160,7 +160,7 @@ with {
 
 type union MyProductionRequestType_derivations
 {
-	MyProductionRequestType_1 myProductionRequestType,
+	@default MyProductionRequestType_1 myProductionRequestType,
 	MyProductionRequestType2_1 myProductionRequestType2,
 	MyProductionRequestType3 myProductionRequestType3,
 	MyProductionRequestType4 myProductionRequestType4
@@ -172,7 +172,7 @@ with {
 
 type union MyProductionRequestType2_derivations
 {
-	MyProductionRequestType2_1 myProductionRequestType2,
+	@default MyProductionRequestType2_1 myProductionRequestType2,
 	MyProductionRequestType3 myProductionRequestType3,
 	MyProductionRequestType4 myProductionRequestType4
 }
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_e.ttcn
index aaeb535cb..25d09c0a4 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_e.ttcn
@@ -101,7 +101,7 @@ type record SubmitRequestType
 
 type union ParentType_derivations
 {
-	ParentType parentType,
+	@default ParentType parentType,
 	RestrictedType restrictedType
 }
 with {
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_elem_in_ct_mod1_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_elem_in_ct_mod1_e.ttcn
index 679d566f3..4436e1e34 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_elem_in_ct_mod1_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_elem_in_ct_mod1_e.ttcn
@@ -103,7 +103,7 @@ with {
 
 type union String_derivations
 {
-	XSD.String string,
+	@default XSD.String string,
 	Stringtype stringtype,
 	Stringtype2 stringtype2
 }
@@ -114,7 +114,7 @@ with {
 
 type union Stringtype_derivations
 {
-	Stringtype stringtype,
+	@default Stringtype stringtype,
 	Stringtype2 stringtype2
 }
 with {
@@ -124,7 +124,7 @@ with {
 
 type union ParentType_derivations
 {
-	ParentType parentType,
+	@default ParentType parentType,
 	MorerestrictedType morerestrictedType,
 	RestrictedType restrictedType
 }
@@ -138,7 +138,7 @@ with {
 
 type union RestrictedType_derivations
 {
-	RestrictedType restrictedType,
+	@default RestrictedType restrictedType,
 	MorerestrictedType morerestrictedType
 }
 with {
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod1_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod1_e.ttcn
index fa45db9f6..c93b359c9 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod1_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod1_e.ttcn
@@ -140,7 +140,7 @@ with {
 
 type union ParentType_derivations
 {
-	ParentType parentType,
+	@default ParentType parentType,
 	ExtendedType extendedType,
 	RestrictedExtendedType restrictedExtendedType,
 	RestrictedType restrictedType,
@@ -159,7 +159,7 @@ with {
 
 type union RestrictedType_derivations
 {
-	RestrictedType restrictedType,
+	@default RestrictedType restrictedType,
 	RestrictedType2 restrictedType2,
 	RestrictedType2_1 restrictedType2_1,
 	RestrictedType3 restrictedType3
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod2_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod2_e.ttcn
index 86ead4382..982937a50 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod2_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod2_e.ttcn
@@ -97,7 +97,7 @@ with {
 
 type union ExtendedType_derivations
 {
-	ExtendedType extendedType,
+	@default ExtendedType extendedType,
 	RestrictedExtendedType restrictedExtendedType
 }
 with {
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_rename_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_rename_e.ttcn
index 3e0faf7c5..c957bbb4d 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_rename_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_rename_e.ttcn
@@ -91,7 +91,7 @@ with {
 
 type union ParentType_derivations
 {
-	ParentType_1 parentType,
+	@default ParentType_1 parentType,
 	RestrictedType_1 restrictedType
 }
 with {
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_simple_cascade_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_simple_cascade_e.ttcn
index f73f79b25..d0cf7f6a7 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_simple_cascade_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_simple_cascade_e.ttcn
@@ -98,7 +98,7 @@ with {
 
 type union String_derivations
 {
-	XSD.String string,
+	@default XSD.String string,
 	Stringtype stringtype,
 	Stringtype2 stringtype2,
 	Stringtype3 stringtype3,
@@ -111,7 +111,7 @@ with {
 
 type union Stringtype_derivations
 {
-	Stringtype stringtype,
+	@default Stringtype stringtype,
 	Stringtype2 stringtype2,
 	Stringtype3 stringtype3,
 	Stringtype4 stringtype4
@@ -123,7 +123,7 @@ with {
 
 type union Stringtype2_derivations
 {
-	Stringtype2 stringtype2,
+	@default Stringtype2 stringtype2,
 	Stringtype3 stringtype3,
 	Stringtype4 stringtype4
 }
@@ -134,7 +134,7 @@ with {
 
 type union Stringtype3_derivations
 {
-	Stringtype3 stringtype3,
+	@default Stringtype3 stringtype3,
 	Stringtype4 stringtype4
 }
 with {
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_simpletype_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_simpletype_e.ttcn
index cf6d70139..e3a61bdcb 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_simpletype_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_simpletype_e.ttcn
@@ -143,7 +143,7 @@ with {
 
 type union String_derivations
 {
-	XSD.String string,
+	@default XSD.String string,
 	Stringtype stringtype,
 	Stringtype2 stringtype2
 }
@@ -154,7 +154,7 @@ with {
 
 type union Stringtype_derivations
 {
-	Stringtype stringtype,
+	@default Stringtype stringtype,
 	Stringtype2 stringtype2
 }
 with {
@@ -164,7 +164,7 @@ with {
 
 type union Integer_derivations
 {
-	XSD.Integer integer_,
+	@default XSD.Integer integer_,
 	ExtInt extInt
 }
 with {
@@ -175,7 +175,7 @@ with {
 
 type union Base64Binary_derivations
 {
-	XSD.Base64Binary base64Binary,
+	@default XSD.Base64Binary base64Binary,
 	CrypBinary crypBinary
 }
 with {
diff --git a/xsdconvert/ComplexType.cc b/xsdconvert/ComplexType.cc
index 6c35d94f6..6a48c5aa4 100644
--- a/xsdconvert/ComplexType.cc
+++ b/xsdconvert/ComplexType.cc
@@ -1207,7 +1207,14 @@ void ComplexType::printToFile(FILE * file, const unsigned level, const bool is_u
     }
 
     for (List<ComplexType*>::iterator c = complexfields.begin(); c; c = c->Next) {
-      c->Data->printToFile(file, level + 1, is_union);
+      if (c == complexfields.begin() && (subsGroup == this || typeSubsGroup == this)) {
+        indent(file, level + 1);
+        fprintf(file, "@default ");
+        c->Data->printToFile(file, 0, is_union);
+      }
+      else {
+        c->Data->printToFile(file, level + 1, is_union);
+      }
       if (c->Next != NULL) {
         fprintf(file, ",\n");
       } else {
-- 
GitLab