diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_list_complextype_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_list_complextype_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..1bf29018a6b24eb6f120ff4e33cc3f8899389bbb --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_list_complextype_e.ttcn @@ -0,0 +1,118 @@ +/******************************************************************************* +* Copyright (c) 2000-2016 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R4C +* +* 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: +* Szabo Bence Janos +* +*******************************************************************************/ +// +// File: www_example_org_list_complextype_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Thu Mar 24 11:50:07 2015 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - list_complextype_e.xsd +// /* xml version = "1.0" */ +// /* targetnamespace = "www.example.org/list/complextype/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_list_complextype { + + +import from XSD all; + + +type record ComplexTypeWithList +{ + record length(3) of XSD.Float elementWithList +} +with { + variant (elementWithList) "name as capitalized"; + variant (elementWithList) "list"; +}; + + +type record length(3) of XSD.Float ElementWithList +with { + variant "list"; + variant "element"; +}; + + +type record ChoiceWithList +{ + union { + record length(3) of XSD.Float element1, + record of XSD.String element2 + } choice +} +with { + variant (choice) "untagged"; + variant (choice.element1) "name as capitalized"; + variant (choice.element1) "list"; + variant (choice.element2) "name as capitalized"; + variant (choice.element2) "list"; +}; + + +type XSD.Token Ipv4 (pattern "IPV4") +with { + variant "name as uncapitalized"; +}; + + +type XSD.Token Ipv6 (pattern "IPV6") +with { + variant "name as uncapitalized"; +}; + + +type record A +{ + XSD.String b, + XSD.Integer c, + record of record { + XSD.Integer e optional, + record { + record length(1 .. infinity) of Ipv4 ipv4addresses, + record length(1 .. infinity) of Ipv6 ipv6addresses + } f optional, + XSD.String g optional + } d_list +} +with { + variant "name as uncapitalized"; + variant (d_list) "untagged"; + variant (d_list[-]) "name as 'd'"; + variant (d_list[-].f.ipv4addresses) "list"; + variant (d_list[-].f.ipv6addresses) "list"; +}; + + +} +with { + encode "XML"; + variant "namespace as 'www.example.org/list/complextype' prefix 'this'"; + 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 5f231064c17d9f375af53a16aa348c956c3722d9..a4d477c0c68eae1825277b8c3a854c4e37f805da 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest.prj +++ b/regression_test/XML/XmlWorkflow/src/xmlTest.prj @@ -162,6 +162,7 @@ <File path="../xsd/attribute_enumeration_variant.xsd" /> <File path="../xsd/including_module.xsd" /> <File path="../xsd/included_without_namespace.xsd" /> + <File path="../xsd/list_complextype.xsd" /> </File_Group> <File_Group name="XmlTest_xsds" > <File path="../XmlTest_xsds/XmlTest_boolean.xsd" /> @@ -394,6 +395,7 @@ <File path="../XmlTest_expectedTtcns/www_XmlTest_org_element_nameInheritance_e.ttcn" /> <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_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 295ee2b4f73536a6bf119b9bf9656a6ba79b138b..164b88872ea3ed212ec6cdfce9ab38073ae3889a 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn +++ b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn @@ -1073,6 +1073,17 @@ group ListTest { } }//tc_ + + testcase tc_list_complextype() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn list_complextype.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_list_complextype_e.ttcn","www_example_org_list_complextype.ttcn", c_numOfDiff_headerAndModuleName); + } + + }//tc_ }//ListTest group UnionTest { @@ -2572,6 +2583,7 @@ control { execute(tc_list_encDec());//Passed execute(tc_integerList());//Passed execute(tc_list_simpletype());//Passed + execute(tc_list_complextype()); //===Float=== execute(tc_float_not_a_number()); diff --git a/regression_test/XML/XmlWorkflow/xsd/list_complextype.xsd b/regression_test/XML/XmlWorkflow/xsd/list_complextype.xsd new file mode 100644 index 0000000000000000000000000000000000000000..1889d039dc57a0e0c977842df4f356d6add1937f --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/list_complextype.xsd @@ -0,0 +1,120 @@ +<!-- + Copyright (c) 2000-2016 Ericsson Telecom AB + 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: + Bence Janos Szabo – initial implementation + --> +<xs:schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="www.example.org/list/complextype" + xmlns:this="www.example.org/list/complextype" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + elementFormDefault="unqualified"> + + +<xs:complexType name="ComplexTypeWithList"> + <xs:sequence> + <xs:element name="ElementWithList"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + <xs:minLength value="3" /> + <xs:maxLength value="3" /> + </xs:restriction> + </xs:simpleType> + </xs:element> + </xs:sequence> +</xs:complexType> + +<xs:element name="ElementWithList"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + <xs:minLength value="3" /> + <xs:maxLength value="3" /> + </xs:restriction> + </xs:simpleType> +</xs:element> + +<xs:complexType name="ChoiceWithList"> + <xs:choice> + <xs:element name="Element1"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + <xs:minLength value="3" /> + <xs:maxLength value="3" /> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="Element2"> + <xs:simpleType> + <xs:list itemType="xs:string" /> + </xs:simpleType> + </xs:element> + </xs:choice> +</xs:complexType> + +<xs:simpleType name="ipv4"> + <xs:restriction base="xs:token"> + <xs:pattern value="IPV4"/> + </xs:restriction> +</xs:simpleType> + +<xs:simpleType name="ipv6"> + <xs:restriction base="xs:token"> + <xs:pattern value="IPV6"/> + </xs:restriction> +</xs:simpleType> + +<xs:complexType name="a"> + <xs:sequence> + <xs:element name="b" type="xs:string"/> + <xs:element name="c" type="xs:integer"/> + <xs:element name="d" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="e" type="xs:integer" minOccurs="0"/> + <xs:element name="f" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="ipv4addresses" minOccurs="0" maxOccurs="1"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="this:ipv4"/> + </xs:simpleType> + <xs:minLength value="1"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="ipv6addresses" minOccurs="0" maxOccurs="1"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="this:ipv6"/> + </xs:simpleType> + <xs:minLength value="1"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="g" type="xs:string" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> +</xs:complexType> + +</xs:schema> diff --git a/xsdconvert/ComplexType.cc b/xsdconvert/ComplexType.cc index caa1a98ab79db9162d7002a4210b64d3db0bbb69..74cac06614d91ae4ae84ca6619c87dc510f0172a 100644 --- a/xsdconvert/ComplexType.cc +++ b/xsdconvert/ComplexType.cc @@ -35,6 +35,7 @@ ComplexType::ComplexType(XMLParser * a_parser, TTCN3Module * a_module, Construct , fromAll(false) , max_alt(0) , skipback(0) +, list(false) , lastType() , actualPath(empty_string) , actfield(this) @@ -62,6 +63,7 @@ ComplexType::ComplexType(ComplexType & other) , fromAll(other.fromAll) , max_alt(other.max_alt) , skipback(other.skipback) +, list(other.list) , lastType(other.lastType) , actualPath(other.actualPath) , actfield(this) @@ -109,6 +111,7 @@ ComplexType::ComplexType(ComplexType * other) , fromAll(false) , max_alt(0) , skipback(0) +, list(false) , lastType() , actualPath(empty_string) , actfield(this) @@ -138,6 +141,7 @@ ComplexType::ComplexType(const SimpleType & other, CT_fromST c) , fromAll(false) , max_alt(0) , skipback(0) +, list(false) , lastType() , actualPath(empty_string) , actfield(this) @@ -580,6 +584,13 @@ void ComplexType::loadWithValues() { } break; case n_list: + if (parent != NULL && parent->basefield == this) { + parent->list = true; + parent->SimpleType::loadWithValues(); + parent->basefield = NULL; + setInvisible(); + break; + } case n_length: case n_minLength: case n_maxLength: @@ -614,8 +625,16 @@ void ComplexType::modifyValues() { if (xsdtype == n_sequence) { skipback = skipback - 1; } + + //embedded simpletype with list in element + if(xsdtype == n_simpleType && list) { + list = false; + return; + } + - if ((xsdtype == n_element || + if ( parent != NULL && + (xsdtype == n_element || xsdtype == n_complexType || xsdtype == n_complexContent || xsdtype == n_all || @@ -626,11 +645,10 @@ void ComplexType::modifyValues() { xsdtype == n_attributeGroup || xsdtype == n_extension || xsdtype == n_restriction || - xsdtype == n_simpleType || + (xsdtype == n_simpleType && !list) || xsdtype == n_simpleContent || (xsdtype == n_sequence && skipback < 0) - ) - && parent != NULL) { + )) { if (!tagNames.empty() && tagNames.back() == parser->getParentTagName()) { if (nillable && tagNames.back() == n_element) { parent->modifyValues(); @@ -2095,3 +2113,4 @@ Mstring ComplexType::findRoot(const BlockValue block_value, SimpleType* elem, co return empty_string; } } + diff --git a/xsdconvert/ComplexType.hh b/xsdconvert/ComplexType.hh index 7b384ad2ce972ef197512055ac02caf993589de7..80a4886e2223cc98ae13c13f62d78047bbb820ac 100644 --- a/xsdconvert/ComplexType.hh +++ b/xsdconvert/ComplexType.hh @@ -71,6 +71,9 @@ private: bool fromAll; unsigned max_alt; int skipback; + //Special use: true if an element of a complextype is restricted to a list + // in a simpletype + bool list; TagName lastType; Mstring actualPath; RootType * actfield; @@ -165,3 +168,4 @@ inline bool compareTypes(ComplexType * lhs, ComplexType * rhs) { #endif /* COMPLEXTYPE_H_ */ +