From 233d2d310ececc3b79662d129f09003b6ad4aeb4 Mon Sep 17 00:00:00 2001 From: ebensza Date: Thu, 2 Jun 2016 12:36:59 +0200 Subject: [PATCH] xsd2ttcn: fixed enumeration restriction (bug 494987) Signed-off-by: ebensza --- ...xample_org_enumeration_restriction3_e.ttcn | 118 ++++++++++++++++++ .../XML/XmlWorkflow/src/xmlTest.prj | 2 + .../XmlWorkflow/src/xmlTest_Testcases.ttcn | 13 ++ .../xsd/enumeration_restriction3.xsd | 53 ++++++++ xsdconvert/ComplexType.cc | 9 ++ xsdconvert/SimpleType.cc | 7 +- 6 files changed, 200 insertions(+), 2 deletions(-) create mode 100644 regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction3_e.ttcn create mode 100644 regression_test/XML/XmlWorkflow/xsd/enumeration_restriction3.xsd 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 0000000..c36a1d3 --- /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 a4d477c..080be3e 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest.prj +++ b/regression_test/XML/XmlWorkflow/src/xmlTest.prj @@ -163,6 +163,7 @@ + @@ -396,6 +397,7 @@ + diff --git a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn index 164b888..f78a24b 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 0000000..8b2e649 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction3.xsd @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsdconvert/ComplexType.cc b/xsdconvert/ComplexType.cc index 74cac06..8367f2a 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 85fbf81..6f52bc2 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::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::iterator facet = other.facets.begin(); facet; facet = facet->Next) { + facets.push_back(facet->Data); + } } } -- 2.34.1