diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction_e.ttcn
index 7b4d4157841ce61d4273378c409b40dacd1788bb..7b10e177fbcfa8cce5e4109f2c5abbbdc7b0b06c 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction_e.ttcn
@@ -154,6 +154,26 @@ type Only_int Ints (
 );
 
 
+type union UnionWithEnumField
+{
+	enumerated {
+		x,
+		none_,
+		type_
+	} alt_,
+	XSD.PositiveInteger alt_1 (1 .. !1000000)
+}
+with {
+  variant "useUnion";
+  variant "element";
+  variant (alt_) "name as ''";
+  variant (alt_) "text 'none_' as 'none'";
+  variant (alt_) "text 'type_' as 'type'";
+  variant (alt_) "text 'x' as ''";
+  variant (alt_1) "name as ''";
+};
+
+
 }
 with {
   encode "XML";
diff --git a/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd b/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd
index ccb09e6bab3a3e2ace53fbd56b3e50fdd787152a..64720a2077b9e1f95d8e2d6993290a350de70608 100644
--- a/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd
+++ b/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd
@@ -125,4 +125,23 @@
 	</xs:restriction>
 </xs:simpleType>
 
+<xs:element name="UnionWithEnumField">
+	<xs:simpleType>
+		<xs:union>
+			<xs:simpleType>
+				<xs:restriction base="xs:normalizedString">
+					<xs:enumeration value=""/>
+					<xs:enumeration value="none"/>
+					<xs:enumeration value="type"/>
+				</xs:restriction>
+			</xs:simpleType>
+			<xs:simpleType>
+				<xs:restriction base="xs:positiveInteger">
+					<xs:maxExclusive value="1000000"/>
+				</xs:restriction>
+			</xs:simpleType>
+		</xs:union>
+	</xs:simpleType>
+</xs:element>
+
 </xs:schema>
diff --git a/xsdconvert/GeneralTypes.hh b/xsdconvert/GeneralTypes.hh
index 01adeac7d23346370c8f39d412da1d49c05277e2..d364accf9f5919a12e5c97287df684da3a4d0670 100644
--- a/xsdconvert/GeneralTypes.hh
+++ b/xsdconvert/GeneralTypes.hh
@@ -148,7 +148,7 @@ public:
   }
 
   QualifiedName(const Mstring& ns, const Mstring nm)
-  : nsuri(ns), name(nm), dup(false) {
+  : nsuri(ns), name(nm), orig_name(nm), dup(false) {
   }
 
   QualifiedName(const Mstring& ns, const Mstring nm, const Mstring orig)