diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction3_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction3_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..c36a1d358fb4f680f0162e83685a69a2693b33f1 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction3_e.ttcn @@ -0,0 +1,118 @@ +/******************************************************************************* +* Copyright (c) 2000-2016 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R5A +* +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Balasko, Jeno +* Szabo, Bence Janos +* +*******************************************************************************/ +// +// File: www_example_org_enumeration_restriction3_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Tue May 31 11:21:08 2015 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - enumeration_restriction3_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/enumeration_restriction3/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_enumeration_restriction3 { + + +import from XSD all; + + +type CType C +with { + variant "element"; +}; + + +type enumerated CType +{ + b2, + uNKNOWN +} +with { + variant "text 'b2' as capitalized"; + variant "text 'uNKNOWN' as capitalized"; +}; + + +type enumerated CTypeEnum +{ + b2 +} +with { + variant "text 'b2' as capitalized"; +}; + + +type CTypeEnum C2 +with { + variant "element"; +}; + + +type enumerated Mountainbikesize +{ + medium, + small +} +with { + variant "name as uncapitalized"; +}; + + +type record FamilyMountainBikeSizes +{ + XSD.String familyMember optional, + Mountainbikesize base +} +with { + variant (familyMember) "attribute"; + variant (base) "untagged"; +}; + + +type record ChildMountainBikeSizes +{ + XSD.String familyMember optional, + enumerated { + small + } base +} +with { + variant (familyMember) "attribute"; + variant (base) "untagged"; +}; + + +} +with { + encode "XML"; + variant "namespace as 'www.example.org/enumeration_restriction3' prefix 'nse'"; + variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/src/xmlTest.prj b/regression_test/XML/XmlWorkflow/src/xmlTest.prj index a4d477c0c68eae1825277b8c3a854c4e37f805da..080be3e59fea336243f73ec3257b18af8da642f2 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest.prj +++ b/regression_test/XML/XmlWorkflow/src/xmlTest.prj @@ -163,6 +163,7 @@ <File path="../xsd/including_module.xsd" /> <File path="../xsd/included_without_namespace.xsd" /> <File path="../xsd/list_complextype.xsd" /> + <File path="../xsd/enumeration_restriction3.xsd" /> </File_Group> <File_Group name="XmlTest_xsds" > <File path="../XmlTest_xsds/XmlTest_boolean.xsd" /> @@ -396,6 +397,7 @@ <File path="../XmlTest_expectedTtcns/www_example_org_attribute_enumeration_variant_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_including_module_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_list_complextype_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_enumeration_restriction3_e.ttcn" /> </File_Group> <File_Group name="XmlTest_src" > <File path="xmlTest_Shell.ttcn" /> diff --git a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn index 164b88872ea3ed212ec6cdfce9ab38073ae3889a..f78a24b2bcdba4437a3ef5ff5af9a7374a9b7c04 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn +++ b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn @@ -1130,6 +1130,18 @@ group UnionTest { } } + testcase tc_enumeration_restriction3() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn enumeration_restriction3.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_enumeration_restriction3_e.ttcn", + "www_example_org_enumeration_restriction3.ttcn", c_numOfDiff_headerAndModuleName); + } + } + + testcase tc_enumeration_remove_dup() runs on xmlTest_CT { f_shellCommandWithVerdict("xsd2ttcn enumeration_remove_dup.xsd","",c_shell_successWithoutWarningAndError) @@ -2599,6 +2611,7 @@ control { execute(tc_union_optional());//CR_TR18883 execute(tc_enumeration_union_restriction()); execute(tc_enumeration_union_restriction2()); + execute(tc_enumeration_restriction3()); execute(tc_enumeration_remove_dup()); //===complex=== execute(tc_complex1()); //Passed diff --git a/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction3.xsd b/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction3.xsd new file mode 100644 index 0000000000000000000000000000000000000000..8b2e6498131e3fb3ff64e6e87409c25058b022fe --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction3.xsd @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="www.example.org/enumeration_restriction3" + xmlns:nse="www.example.org/enumeration_restriction3"> + +<element name="C"> + <simpleType> + <restriction base="nse:CType" /> + </simpleType> +</element> + +<simpleType name="CType"> + <restriction base="string"> + <maxLength value="32" /> + <enumeration value="B2" /> + <enumeration value="UNKNOWN" /> + </restriction> +</simpleType> + +<simpleType name="CTypeEnum"> + <restriction base="nse:CType" > + <enumeration value="B2" /> + </restriction> +</simpleType> + +<element name="C2" type="nse:CTypeEnum"/> + + +<simpleType name="mountainbikesize"> + <restriction base="string"> + <enumeration value="small"/> + <enumeration value="medium"/> + </restriction> +</simpleType> + +<complexType name="FamilyMountainBikeSizes"> + <simpleContent> + <extension base="nse:mountainbikesize"> + <attribute name="familyMember" type="string" /> + </extension> + </simpleContent> +</complexType> + +<complexType name="ChildMountainBikeSizes"> + <simpleContent> + <restriction base="nse:FamilyMountainBikeSizes" > + <enumeration value="small"/> + </restriction> + </simpleContent> +</complexType> + + +</schema> diff --git a/xsdconvert/ComplexType.cc b/xsdconvert/ComplexType.cc index 74cac06614d91ae4ae84ca6619c87dc510f0172a..8367f2a018026e1d574fc8b5d151b04fb26b7c85 100644 --- a/xsdconvert/ComplexType.cc +++ b/xsdconvert/ComplexType.cc @@ -1782,6 +1782,15 @@ void ComplexType::resolveSimpleTypeExtension() { st->addToNameDepList(basefield); basefield->nameDep = st; addNameSpaceAsVariant(basefield, st); + const Mstring old_type = basefield->getType().originalValueWoPrefix; + basefield->applyReference(*st); + // If st has enumeration then the type is restored to the original value + // because enumerations cannot be extended here and this way we just + // we just create an alias. + if (st->getEnumeration().modified) { + basefield->setTypeValue(old_type); + basefield->getEnumeration().modified = false; + } } } else if(!isBuiltInType(basefield->getType().convertedValue)){ printError(module->getSchemaname(), name.convertedValue, diff --git a/xsdconvert/SimpleType.cc b/xsdconvert/SimpleType.cc index 85fbf8148b7ea12f7b0580e687a056a0d6522562..6f52bc2447a59b1d00db3a7b7d42181bbe10eabb 100644 --- a/xsdconvert/SimpleType.cc +++ b/xsdconvert/SimpleType.cc @@ -1149,8 +1149,11 @@ EnumerationType::EnumerationType(SimpleType * a_simpleType) void EnumerationType::applyReference(const EnumerationType & other) { if (!modified) modified = other.modified; - for (List<Mstring>::iterator facet = other.facets.begin(); facet; facet = facet->Next) { - facets.push_back(facet->Data); + if ((other.parent->getXsdtype() == n_NOTSET && parent->getMode() != SimpleType::restrictionMode) + || parent->getXsdtype() == n_simpleType) { + for (List<Mstring>::iterator facet = other.facets.begin(); facet; facet = facet->Next) { + facets.push_back(facet->Data); + } } }