diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/http_www_example_org_list_minmaxoccurs_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/http_www_example_org_list_minmaxoccurs_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..60fe6571a77be7db81be9faf3d97742e284a79aa --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/http_www_example_org_list_minmaxoccurs_e.ttcn @@ -0,0 +1,303 @@ +/******************************************************************************* +* Copyright (c) 2000-2016 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/6 R0A +* +* 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: http_www_example_org_list_minmaxoccurs_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Mon Nov 14 10:11:16 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - listMinMaxOccurs_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "http://www.example.org/list/minmaxoccurs/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module http_www_example_org_list_minmaxoccurs_e { + + +import from XSD all; + + +type record SequenceList +{ + record length(1 .. infinity) of XSD.String element0, + record length(1 .. infinity) of XSD.String element1 optional, + record length(0 .. 2) of record length(1 .. infinity) of XSD.String element2_list, + record of record length(1 .. infinity) of XSD.String element3_list, + record of record of XSD.String element4_list +} +with { + variant "element"; + variant (element0) "name as capitalized"; + variant (element0) "list"; + variant (element1) "name as capitalized"; + variant (element1) "list"; + variant (element2_list) "untagged"; + variant (element2_list[-]) "name as 'Element2'"; + variant (element2_list[-]) "list"; + variant (element3_list) "untagged"; + variant (element3_list[-]) "name as 'Element3'"; + variant (element3_list[-]) "list"; + variant (element4_list) "untagged"; + variant (element4_list[-]) "name as 'Element4'"; + variant (element4_list[-]) "list"; +}; + + +type record SequenceList2 +{ + record of XSD.String element0 length(4), + record of XSD.String element1 length(4) optional, + record length(0 .. 2) of record of XSD.String element2_list length(4), + record of record of XSD.String element3_list length(4) +} +with { + variant "element"; + variant (element0) "name as capitalized"; + variant (element0) "list"; + variant (element1) "name as capitalized"; + variant (element1) "list"; + variant (element2_list) "untagged"; + variant (element2_list[-]) "name as 'Element2'"; + variant (element2_list[-]) "list"; + variant (element3_list) "untagged"; + variant (element3_list[-]) "name as 'Element3'"; + variant (element3_list[-]) "list"; +}; + + +type record SequenceList3 +{ + record length(3) of XSD.String element0 length(4), + record length(3) of XSD.String element1 length(4) optional, + record length(0 .. 2) of record length(3) of XSD.String element2_list length(4), + record of record length(3) of XSD.String element3_list length(4) +} +with { + variant "element"; + variant (element0) "name as capitalized"; + variant (element0) "list"; + variant (element1) "name as capitalized"; + variant (element1) "list"; + variant (element2_list) "untagged"; + variant (element2_list[-]) "name as 'Element2'"; + variant (element2_list[-]) "list"; + variant (element3_list) "untagged"; + variant (element3_list[-]) "name as 'Element3'"; + variant (element3_list[-]) "list"; +}; + + +type record SequenceList4 +{ + record of record { + record length(3) of XSD.String element0 length(4), + record length(3) of XSD.String element1 length(4) optional, + record length(0 .. 2) of record length(3) of XSD.String element2_list length(4), + record of record length(3) of XSD.String element3_list length(4) + } sequence_list +} +with { + variant "element"; + variant (sequence_list) "untagged"; + variant (sequence_list[-]) "untagged"; + variant (sequence_list[-].element0) "name as capitalized"; + variant (sequence_list[-].element0) "list"; + variant (sequence_list[-].element1) "name as capitalized"; + variant (sequence_list[-].element1) "list"; + variant (sequence_list[-].element2_list) "untagged"; + variant (sequence_list[-].element2_list[-]) "name as 'Element2'"; + variant (sequence_list[-].element2_list[-]) "list"; + variant (sequence_list[-].element3_list) "untagged"; + variant (sequence_list[-].element3_list[-]) "name as 'Element3'"; + variant (sequence_list[-].element3_list[-]) "list"; +}; + + +type record ChoiceWithList +{ + union { + record length(3) of XSD.String element0 length(4), + record length(0 .. 1) of record length(3) of XSD.String element1_list length(4), + record length(1) of record length(3) of XSD.String element2_list length(4), + record length(1 .. infinity) of record length(3) of XSD.String element3_list length(4), + record length(2 .. 3) of record length(3) of XSD.String element4_list, + record length(2 .. infinity) of record length(3) of XSD.String element5_list + } choice +} +with { + variant (choice) "untagged"; + variant (choice.element0) "name as capitalized"; + variant (choice.element0) "list"; + variant (choice.element1_list) "untagged"; + variant (choice.element1_list[-]) "name as 'Element1'"; + variant (choice.element1_list[-]) "list"; + variant (choice.element2_list) "untagged"; + variant (choice.element2_list[-]) "name as 'Element2'"; + variant (choice.element2_list[-]) "list"; + variant (choice.element3_list) "untagged"; + variant (choice.element3_list[-]) "name as 'Element3'"; + variant (choice.element3_list[-]) "list"; + variant (choice.element4_list) "untagged"; + variant (choice.element4_list[-]) "name as 'Element4'"; + variant (choice.element4_list[-]) "list"; + variant (choice.element5_list) "untagged"; + variant (choice.element5_list[-]) "name as 'Element5'"; + variant (choice.element5_list[-]) "list"; +}; + + +type record ChoiceWithList2 +{ + union { + record of XSD.Float element0, + record length(0 .. 1) of record of XSD.Float element1_list, + record length(1) of record of XSD.Float element2_list, + record length(2 .. 3) of record of XSD.Float element3_list, + record length(1 .. infinity) of record of XSD.Float element4_list, + XSD.Integer element5 + } choice +} +with { + variant (choice) "untagged"; + variant (choice.element0) "name as capitalized"; + variant (choice.element0) "list"; + variant (choice.element1_list) "untagged"; + variant (choice.element1_list[-]) "name as 'Element1'"; + variant (choice.element1_list[-]) "list"; + variant (choice.element2_list) "untagged"; + variant (choice.element2_list[-]) "name as 'Element2'"; + variant (choice.element2_list[-]) "list"; + variant (choice.element3_list) "untagged"; + variant (choice.element3_list[-]) "name as 'Element3'"; + variant (choice.element3_list[-]) "list"; + variant (choice.element4_list) "untagged"; + variant (choice.element4_list[-]) "name as 'Element4'"; + variant (choice.element4_list[-]) "list"; + variant (choice.element5) "name as capitalized"; +}; + + +type record ChoiceWithList3 +{ + record of union { + record of XSD.Float element0, + record length(0 .. 1) of record of XSD.Float element1_list, + record length(1) of record of XSD.Float element2_list, + record length(2 .. 3) of record of XSD.Float element3_list, + record length(1 .. infinity) of record of XSD.Float element4_list, + XSD.Integer element5 + } choice_list +} +with { + variant (choice_list) "untagged"; + variant (choice_list[-]) "untagged"; + variant (choice_list[-].element0) "name as capitalized"; + variant (choice_list[-].element0) "list"; + variant (choice_list[-].element1_list) "untagged"; + variant (choice_list[-].element1_list[-]) "name as 'Element1'"; + variant (choice_list[-].element1_list[-]) "list"; + variant (choice_list[-].element2_list) "untagged"; + variant (choice_list[-].element2_list[-]) "name as 'Element2'"; + variant (choice_list[-].element2_list[-]) "list"; + variant (choice_list[-].element3_list) "untagged"; + variant (choice_list[-].element3_list[-]) "name as 'Element3'"; + variant (choice_list[-].element3_list[-]) "list"; + variant (choice_list[-].element4_list) "untagged"; + variant (choice_list[-].element4_list[-]) "name as 'Element4'"; + variant (choice_list[-].element4_list[-]) "list"; + variant (choice_list[-].element5) "name as capitalized"; +}; + + +type record ChoiceWithList4 +{ + union { + record length(0 .. 1) of record of XSD.Float element0_list, + record length(1) of record of XSD.Float element1_list, + record length(1) of record length(3) of XSD.String element2_list, + record length(1) of record length(5) of XSD.String element3_list length(4), + record length(1) of record length(1 .. infinity) of XSD.String element4_list + } choice +} +with { + variant (choice) "untagged"; + variant (choice.element0_list) "untagged"; + variant (choice.element0_list[-]) "name as 'Element0'"; + variant (choice.element0_list[-]) "list"; + variant (choice.element1_list) "untagged"; + variant (choice.element1_list[-]) "name as 'Element1'"; + variant (choice.element1_list[-]) "list"; + variant (choice.element2_list) "untagged"; + variant (choice.element2_list[-]) "name as 'Element2'"; + variant (choice.element2_list[-]) "list"; + variant (choice.element3_list) "untagged"; + variant (choice.element3_list[-]) "name as 'Element3'"; + variant (choice.element3_list[-]) "list"; + variant (choice.element4_list) "untagged"; + variant (choice.element4_list[-]) "name as 'Element4'"; + variant (choice.element4_list[-]) "list"; +}; + + +type record ChoiceWithList5 +{ + union { + record of record of XSD.Float element_list, + record length(1 .. infinity) of record of XSD.Float element1_list, + record length(1 .. infinity) of record length(3) of XSD.String element2_list, + record length(1 .. infinity) of record length(3) of XSD.String element3_list length(4), + record length(1 .. infinity) of record length(1 .. infinity) of XSD.String element4_list + } choice +} +with { + variant (choice) "untagged"; + variant (choice.element_list) "untagged"; + variant (choice.element_list[-]) "name as 'Element.'"; + variant (choice.element_list[-]) "list"; + variant (choice.element1_list) "untagged"; + variant (choice.element1_list[-]) "name as 'Element1'"; + variant (choice.element1_list[-]) "list"; + variant (choice.element2_list) "untagged"; + variant (choice.element2_list[-]) "name as 'Element2'"; + variant (choice.element2_list[-]) "list"; + variant (choice.element3_list) "untagged"; + variant (choice.element3_list[-]) "name as 'Element3'"; + variant (choice.element3_list[-]) "list"; + variant (choice.element4_list) "untagged"; + variant (choice.element4_list[-]) "name as 'Element4'"; + variant (choice.element4_list[-]) "list"; +}; + + +} +with { + encode "XML"; + variant "namespace as 'http://www.example.org/list/minmaxoccurs/e' prefix 'this'"; + variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} 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 index 7f075be61e0fb257ae6ee90eb9273b67f93708c2..c5beda92b3dd1ef896d95672d49a07523798b485 100644 --- 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 @@ -121,8 +121,8 @@ type record A record of record { XSD.Integer e optional, record { - record length(1 .. infinity) of Ipv4 ipv4addresses, - record length(1 .. infinity) of Ipv6 ipv6addresses + record length(1 .. infinity) of Ipv4 ipv4addresses optional, + record length(1 .. infinity) of Ipv6 ipv6addresses optional } f optional, XSD.String g optional } d_list diff --git a/regression_test/XML/XmlWorkflow/src/xmlTest.prj b/regression_test/XML/XmlWorkflow/src/xmlTest.prj index 5b19850d3a097c34b464aa35931a21939f69de5f..56e1f649dff9aa1ec8fb40864a64deb88fa922c1 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest.prj +++ b/regression_test/XML/XmlWorkflow/src/xmlTest.prj @@ -168,6 +168,7 @@ <File path="../xsd/www_example_org_pref1.xsd" /> <File path="../xsd/www_example_org_pref2.xsd" /> <File path="../xsd/www_example_org_pref3.xsd" /> + <File path="../xsd/listMinMaxOccurs.xsd" /> </File_Group> <File_Group name="XmlTest_xsds" > <File path="../XmlTest_xsds/XmlTest_boolean.xsd" /> @@ -406,6 +407,7 @@ <File path="../XmlTest_expectedTtcns/www_example_org_pref1_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_pref2_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_pref3_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/http_www_example_org_list_minmaxoccurs_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 ebfa638742f180a328245a0c8d5cdded5716f477..eb5ac49310fcc394af9b3bd7368787c841c7dc4e 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn +++ b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn @@ -1083,6 +1083,17 @@ group ListTest { } }//tc_ + + testcase tc_list_minmaxoccurs() runs on xmlTest_CT { + + f_shellCommandWithVerdict(xsd2ttcn_command & " listMinMaxOccurs.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "http_www_example_org_list_minmaxoccurs_e.ttcn","http_www_example_org_list_minmaxoccurs.ttcn", c_numOfDiff_headerAndModuleName); + } + + }//tc_ }//ListTest group UnionTest { @@ -2622,6 +2633,7 @@ control { execute(tc_integerList());//Passed execute(tc_list_simpletype());//Passed execute(tc_list_complextype()); + execute(tc_list_minmaxoccurs()); //===Float=== execute(tc_float_not_a_number()); diff --git a/regression_test/XML/XmlWorkflow/xsd/listMinMaxOccurs.xsd b/regression_test/XML/XmlWorkflow/xsd/listMinMaxOccurs.xsd new file mode 100644 index 0000000000000000000000000000000000000000..b30765878e40ef95666db5a5630f6592350b21ab --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/listMinMaxOccurs.xsd @@ -0,0 +1,546 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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: + Szabo, Bence Janos +--> +<xs:schema +xmlns:xs="http://www.w3.org/2001/XMLSchema" +xmlns="http://www.w3.org/2001/XMLSchema" +xmlns:this="http://www.example.org/list/minmaxoccurs" +targetNamespace="http://www.example.org/list/minmaxoccurs"> + +<xs:element name="SequenceList"> + <xs:complexType> + <xs:sequence> + <xs:element name="Element0" minOccurs="1" maxOccurs="1"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:string" /> + </xs:simpleType> + <xs:minLength value="1" /> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="Element1" minOccurs="0" maxOccurs="1"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:string" /> + </xs:simpleType> + <xs:minLength value="1" /> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="Element2" minOccurs="0" maxOccurs="2"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:string" /> + </xs:simpleType> + <xs:minLength value="1" /> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="Element3" minOccurs="0" maxOccurs="unbounded"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:string" /> + </xs:simpleType> + <xs:minLength value="1" /> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="Element4" minOccurs="0" maxOccurs="unbounded"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:string" /> + </xs:simpleType> + </xs:restriction> + </xs:simpleType> + </xs:element> + </xs:sequence> + </xs:complexType> +</xs:element> + + +<xs:element name="SequenceList2"> + <xs:complexType> + <xs:sequence> + <xs:element name="Element0" minOccurs="1" maxOccurs="1"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element1" minOccurs="0" maxOccurs="1"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element2" minOccurs="0" maxOccurs="2"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element3" minOccurs="0" maxOccurs="unbounded"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + </restriction> + </simpleType> + </xs:element> + </xs:sequence> + </xs:complexType> +</xs:element> + + +<xs:element name="SequenceList3"> + <xs:complexType> + <xs:sequence> + <xs:element name="Element0" minOccurs="1" maxOccurs="1"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="3"/> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element1" minOccurs="0" maxOccurs="1"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="3"/> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element2" minOccurs="0" maxOccurs="2"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="3"/> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element3" minOccurs="0" maxOccurs="unbounded"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="3"/> + </restriction> + </simpleType> + </xs:element> + </xs:sequence> + </xs:complexType> +</xs:element> + +<xs:element name="SequenceList4"> + <xs:complexType> + <xs:sequence minOccurs="0" maxOccurs="unbounded"> + <xs:element name="Element0" minOccurs="1" maxOccurs="1"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="3"/> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element1" minOccurs="0" maxOccurs="1"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="3"/> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element2" minOccurs="0" maxOccurs="2"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="3"/> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element3" minOccurs="0" maxOccurs="unbounded"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="3"/> + </restriction> + </simpleType> + </xs:element> + </xs:sequence> + </xs:complexType> +</xs:element> + +<xs:complexType name="ChoiceWithList"> + <xs:choice> + <xs:element name="Element0"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="3"/> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element1" minOccurs="0"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="3"/> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element2" minOccurs="0"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="3"/> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element3" minOccurs="0" maxOccurs="unbounded"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="3"/> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element4" minOccurs="2" maxOccurs="3"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:string" /> + </xs:simpleType> + <xs:minLength value="3" /> + <xs:maxLength value="3" /> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="Element5" minOccurs="2" maxOccurs="unbounded"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:string" /> + </xs:simpleType> + <xs:minLength value="3" /> + <xs:maxLength value="3" /> + </xs:restriction> + </xs:simpleType> + </xs:element> + </xs:choice> +</xs:complexType> + +<xs:complexType name="ChoiceWithList2"> + <xs:choice> + <xs:element name="Element0"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element1" minOccurs="0"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element2" minOccurs="0"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element3" minOccurs="2" maxOccurs="3"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element4" minOccurs="0" maxOccurs="unbounded"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element5" type="integer"/> + </xs:choice> +</xs:complexType> + +<xs:complexType name="ChoiceWithList3"> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="Element0"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element1" minOccurs="0"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element2" minOccurs="0"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element3" minOccurs="2" maxOccurs="3"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element4" minOccurs="0" maxOccurs="unbounded"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element5" type="integer"/> + </xs:choice> +</xs:complexType> + + + + +<xs:complexType name="ChoiceWithList4"> + <xs:choice> + <xs:element name="Element0" minOccurs="0"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element1" minOccurs="0"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element2" minOccurs="0"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:string" /> + </xs:simpleType> + <xs:minLength value="3" /> + <xs:maxLength value="3" /> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="Element3" minOccurs="0"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="5"/> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element4" minOccurs="0"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:string" /> + </xs:simpleType> + <xs:minLength value="1" /> + </xs:restriction> + </xs:simpleType> + </xs:element> + </xs:choice> +</xs:complexType> + + +<xs:complexType name="ChoiceWithList5"> + <xs:choice> + <xs:element name="Element." minOccurs="0" maxOccurs="unbounded"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element1" minOccurs="0" maxOccurs="unbounded"> + <xs:simpleType> + <xs:list itemType="xs:float" /> + </xs:simpleType> + </xs:element> + <xs:element name="Element2" minOccurs="0" maxOccurs="unbounded"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:string" /> + </xs:simpleType> + <xs:minLength value="3" /> + <xs:maxLength value="3" /> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="Element3" minOccurs="0" maxOccurs="unbounded"> + <simpleType> + <restriction> + <simpleType> + <list> + <simpleType> + <restriction base="string"> + <length value="4" /> + </restriction> + </simpleType> + </list> + </simpleType> + <length value="3"/> + </restriction> + </simpleType> + </xs:element> + <xs:element name="Element4" minOccurs="0" maxOccurs="unbounded"> + <xs:simpleType> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:string" /> + </xs:simpleType> + <xs:minLength value="1" /> + </xs:restriction> + </xs:simpleType> + </xs:element> + </xs:choice> +</xs:complexType> + +</xs:schema> diff --git a/xsdconvert/AttributeType.cc b/xsdconvert/AttributeType.cc index 73e6475dc29de05b9118479488d3c2881272f926..6db3daffe38263f9ba38314a90e8866e1febe52a 100644 --- a/xsdconvert/AttributeType.cc +++ b/xsdconvert/AttributeType.cc @@ -31,10 +31,6 @@ AttributeType::AttributeType(const AttributeType & other) , origModule(other.getModule()) { } -AttributeType::~AttributeType() { - -} - void AttributeType::modifyValues() { if (parser->getActualTagName() == n_attribute || parser->getActualTagName() == n_anyAttribute) { ((ComplexType*) parent)->modifyAttributeParent(); diff --git a/xsdconvert/AttributeType.hh b/xsdconvert/AttributeType.hh index 3ab8072e1be92730ef65baf2a2f4ee954396f2cd..102470152c20fa012ae2e881cd5050733e8b59f4 100644 --- a/xsdconvert/AttributeType.hh +++ b/xsdconvert/AttributeType.hh @@ -43,7 +43,6 @@ public: explicit AttributeType(ComplexType * a_complextype); AttributeType(const AttributeType & other); AttributeType & operator=(const AttributeType & rhs); - virtual ~AttributeType(); void setTypeOfField(const Mstring& in); void setNameOfField(const Mstring& in); diff --git a/xsdconvert/ComplexType.cc b/xsdconvert/ComplexType.cc index cfd9d41292710eb4fa704f2ac676769522549d6d..7ebe8bc44a289ee8ef24f70f6e1bf7f583d1febe 100644 --- a/xsdconvert/ComplexType.cc +++ b/xsdconvert/ComplexType.cc @@ -33,6 +33,9 @@ ComplexType::ComplexType(XMLParser * a_parser, TTCN3Module * a_module, Construct , with_union(false) , first_child(false) , fromAll(false) +, listPrint(false) +, listMinOccurs(1) +, listMaxOccurs(1) , max_alt(0) , skipback(0) , lastType() @@ -60,6 +63,9 @@ ComplexType::ComplexType(ComplexType & other) , with_union(other.with_union) , first_child(other.first_child) , fromAll(other.fromAll) +, listPrint(other.listPrint) +, listMinOccurs(other.listMinOccurs) +, listMaxOccurs(other.listMaxOccurs) , max_alt(other.max_alt) , skipback(other.skipback) , lastType(other.lastType) @@ -107,6 +113,9 @@ ComplexType::ComplexType(ComplexType * other) , with_union(false) , first_child(false) , fromAll(false) +, listPrint(false) +, listMinOccurs(1) +, listMaxOccurs(1) , max_alt(0) , skipback(0) , lastType() @@ -136,6 +145,9 @@ ComplexType::ComplexType(const SimpleType & other, CT_fromST c) , with_union(false) , first_child(false) , fromAll(false) +, listPrint(false) +, listMinOccurs(1) +, listMaxOccurs(1) , max_alt(0) , skipback(0) , lastType() @@ -283,7 +295,7 @@ void ComplexType::loadWithValues() { case n_restriction: mode = restrictionMode; //If it is an xsd:union then call SimpleType::loadWithValues - if (parent != NULL && parent->with_union) { + if (parent != NULL && parent->with_union && parent->hasVariant(Mstring("useUnion"))) { SimpleType::loadWithValues(); break; } @@ -549,11 +561,13 @@ void ComplexType::loadWithValues() { xsdtype = parser->getActualTagName(); cmode = CT_simpletype_mode; Mstring fieldname; - if (with_union) { + if (with_union && hasVariant(Mstring("useUnion"))) { if (max_alt == 0) { fieldname = Mstring("alt_"); } else { - fieldname = mprintf("alt_%d", max_alt); + expstring_t new_name = mprintf("alt_%d", max_alt); + fieldname = new_name; + Free(new_name); } max_alt++; ComplexType * field = new ComplexType(this); @@ -587,10 +601,38 @@ void ComplexType::loadWithValues() { break; case n_list: if (parent != NULL && parent->basefield == this) { - parent->SimpleType::loadWithValues(); + if (parent->getMaxOccurs() == 1) { // optional or minOccurs = maxOccurs = 1 + if (parent->getMinOccurs() == 0) { + parent->isOptional = true; + if (parent->parent != NULL && parent->parent->getXsdtype() == n_choice) { + parent->listPrint = true; + parent->listMinOccurs = parent->getMinOccurs(); + parent->listMaxOccurs = parent->getMaxOccurs(); + } + } + } else if (parent->parent != NULL){ + parent->listPrint = true; + parent->listMinOccurs = parent->getMinOccurs(); + parent->listMaxOccurs = parent->getMaxOccurs(); + } parent->basefield = NULL; + parent->SimpleType::loadWithValues(); setInvisible(); } else if(parent != NULL) { + if (getMaxOccurs() == 1) { // optional or minOccurs = maxOccurs = 1 + if (getMinOccurs() == 0) { + isOptional = true; + if (parent->getXsdtype() == n_choice) { + listPrint = true; + listMinOccurs = getMinOccurs(); + listMaxOccurs = getMaxOccurs(); + } + } + } else { + listPrint = true; + listMinOccurs = getMinOccurs(); + listMaxOccurs = getMaxOccurs(); + } SimpleType::loadWithValues(); } break; @@ -628,7 +670,6 @@ void ComplexType::modifyValues() { if (xsdtype == n_sequence) { skipback = skipback - 1; } - if ( parent != NULL && (xsdtype == n_element || @@ -969,7 +1010,7 @@ void ComplexType::setFieldPaths(Mstring path) { void ComplexType::finalModification2() { //Call SimpleType finalModification SimpleType::finalModification(); - + //Set isOptional field isOptional = isOptional || (getMinOccurs() == 0 && getMaxOccurs() == 1); @@ -1034,7 +1075,9 @@ void ComplexType::finalModification2() { if (number == 0) { field->Data->name.upload(Mstring("alt_")); } else { - field->Data->name.upload(Mstring(mprintf("alt_%d", number))); + expstring_t new_name = mprintf("alt_%d", number); + field->Data->name.upload(Mstring(new_name)); + Free(new_name); } number++; } @@ -1191,24 +1234,39 @@ void ComplexType::printToFile(FILE * file, const unsigned level, const bool is_u if ((multiplicity > 1) && getReference().get_ref()) { fprintf(file, "%s.", getReference().get_ref()->getModule()->getModulename().c_str()); } - if (field_is_record || field_is_union) { + if (field_is_record || field_is_union || listPrint) { + unsigned long long int tempMin = getMinOccurs(); + unsigned long long int tempMax = getMaxOccurs(); + if (listPrint) { + setMinOccurs(listMinOccurs); + setMaxOccurs(listMaxOccurs); + } printMinOccursMaxOccurs(file, with_union, !first_child || parent->getXsdtype() != n_choice); - fprintf(file, "%s {\n", getType().convertedValue.c_str()); - for (List<AttributeType*>::iterator f = attribfields.begin(); f; f = f->Next) { - f->Data->printToFile(file, level + 1); - if (f->Next != NULL || !complexfields.empty()) { - fprintf(file, ",\n"); - } else { - fprintf(file, "\n"); - } + if (listPrint) { + setMinOccurs(tempMin); + setMaxOccurs(tempMax); } + if (listPrint && complexfields.size() == 0) { + printMinOccursMaxOccurs(file, false); + fprintf(file, "%s ",getType().convertedValue.c_str()); + } else { + fprintf(file, "%s {\n", getType().convertedValue.c_str()); + for (List<AttributeType*>::iterator f = attribfields.begin(); f; f = f->Next) { + f->Data->printToFile(file, level + 1); + if (f->Next != NULL || !complexfields.empty()) { + fprintf(file, ",\n"); + } else { + fprintf(file, "\n"); + } + } - for (List<ComplexType*>::iterator c = complexfields.begin(); c; c = c->Next) { - c->Data->printToFile(file, level + 1, is_union); - if (c->Next != NULL) { - fprintf(file, ",\n"); - } else { - fprintf(file, "\n"); + for (List<ComplexType*>::iterator c = complexfields.begin(); c; c = c->Next) { + c->Data->printToFile(file, level + 1, is_union); + if (c->Next != NULL) { + fprintf(file, ",\n"); + } else { + fprintf(file, "\n"); + } } } } else { @@ -1230,7 +1288,7 @@ void ComplexType::printToFile(FILE * file, const unsigned level, const bool is_u } } } - if (field_is_record || field_is_union) { + if ((field_is_record || field_is_union) && !listPrint) { indent(file, level); fprintf(file, "} "); } @@ -1443,16 +1501,14 @@ void ComplexType::setMinMaxOccurs(const unsigned long long min, const unsigned l } if (parent != NULL && parent->getXsdtype() == n_choice) { name.list_extension = true; - if ((parent != NULL && parent->getXsdtype() == n_choice)) { - if (parent->first_child == false && getMinOccurs() == 0) { - parent->first_child = true; - with_union = true; - first_child = false; - } else { - with_union = true; - first_child = true; - } - } + if (parent->first_child == false && getMinOccurs() == 0) { + parent->first_child = true; + with_union = true; + first_child = false; + } else { + with_union = true; + first_child = true; + } } } } @@ -1481,8 +1537,8 @@ void ComplexType::applyNamespaceAttribute(VariantMode varLabel, const Mstring& n // of XML Schema. It is either ##any, ##other, ##local, ##targetNamespace, // or a list of (namespace reference | ##local | ##targetNamespace). for (List<Mstring>::iterator ns = namespaces.begin(); ns; ns = ns->Next) { - static const Mstring xxany("##any"), xxother("##other"), xxlocal("##local"), - xxtargetNamespace("##targetNamespace"); + static char xxany[] = "##any", xxother[] = "##other", xxlocal[] = "##local", + xxtargetNamespace[] = "##targetNamespace"; if (!first) any_ns += ','; if (ns->Data == xxany) { @@ -1662,14 +1718,14 @@ void ComplexType::resolveAttributeGroup(SimpleType * st) { } } for (List<AttributeType*>::iterator attr = ct->attribfields.begin(); attr; attr = attr->Next) { - AttributeType * attrib = new AttributeType(*attr->Data); - attr->Data->setOrigModule(ct->getModule()); - if (addNameSpaceas) { - attrib->addVariant(V_namespaceAs, ct->getModule()->getTargetNamespace()); - } if (anyAttrib != NULL && attr->Data->isAnyAttribute()) { anyAttrib->Data->addNameSpaceAttribute(attr->Data->getNameSpaceAttribute()); } else { + AttributeType * attrib = new AttributeType(*attr->Data); + attr->Data->setOrigModule(ct->getModule()); + if (addNameSpaceas) { + attrib->addVariant(V_namespaceAs, ct->getModule()->getTargetNamespace()); + } //Nillable attribute placement is hard... if (parent->nillable && parent->parent != NULL) { parent->parent->attribfields.push_back(attrib); diff --git a/xsdconvert/ComplexType.hh b/xsdconvert/ComplexType.hh index 1561689e7140d8a41bf82e78338cfb37c405612d..dd40d9bef858c2ee0d814f87073518f0235e25f3 100644 --- a/xsdconvert/ComplexType.hh +++ b/xsdconvert/ComplexType.hh @@ -69,7 +69,12 @@ private: bool with_union; bool first_child; bool fromAll; - unsigned max_alt; + bool listPrint; // true if embeddedList was true or wasInEmbeddedList was true + // both will be changed to false during the conversion. This + // variable remembers. + unsigned long long int listMinOccurs; // MinOccurs of the list when in an element + unsigned long long int listMaxOccurs; // MaxOccurs of the list when in an element + unsigned int max_alt; int skipback; TagName lastType; Mstring actualPath; diff --git a/xsdconvert/GeneralTypes.hh b/xsdconvert/GeneralTypes.hh index ccc8f442fcf44c70eda3cb8bc8a3da6ee8c2adca..01adeac7d23346370c8f39d412da1d49c05277e2 100644 --- a/xsdconvert/GeneralTypes.hh +++ b/xsdconvert/GeneralTypes.hh @@ -172,6 +172,6 @@ enum wanted { want_CT, want_ST, want_BOTH }; -static const Mstring XMLSchema("http://www.w3.org/2001/XMLSchema"); +static const char XMLSchema[] = "http://www.w3.org/2001/XMLSchema"; #endif /*GENERAL_TYPES_H_*/ diff --git a/xsdconvert/RootType.hh b/xsdconvert/RootType.hh index a3fe1ae4cd41f102ed139a2004cc96c90456d8e5..9383a5368cf8d79950fd6b7e6a0cb13c72e4df4c 100644 --- a/xsdconvert/RootType.hh +++ b/xsdconvert/RootType.hh @@ -215,11 +215,11 @@ public: max_mod = true; } - const bool getMinMod() const { + bool getMinMod() const { return min_mod; } - const bool getMaxMod() const { + bool getMaxMod() const { return max_mod; } diff --git a/xsdconvert/SimpleType.cc b/xsdconvert/SimpleType.cc index e4d974056d7f39fa9f93cf40166eb90465afe5b6..afd41519b3b89c9a0865d8de937d5220ea79b1d4 100644 --- a/xsdconvert/SimpleType.cc +++ b/xsdconvert/SimpleType.cc @@ -646,6 +646,7 @@ void SimpleType::referenceForCT(ComplexType * found_CT) { expstring_t tmp_string = mprintf("{%s:=%d}", field->Data->getName().convertedValue.c_str(), val); value.items_with_value.push_back(Mstring(tmp_string)); + Free(tmp_string); break; } } @@ -658,6 +659,7 @@ void SimpleType::referenceForCT(ComplexType * found_CT) { expstring_t tmp_string = mprintf("{%s:=%f}", field->Data->getName().convertedValue.c_str(), val); value.items_with_value.push_back(Mstring(tmp_string)); + Free(tmp_string); break; } } @@ -667,6 +669,7 @@ void SimpleType::referenceForCT(ComplexType * found_CT) { expstring_t tmp_string = mprintf("{%s:=\"%s\"}", field->Data->getName().convertedValue.c_str(), itemMisc->Data.c_str()); value.items_with_value.push_back(Mstring(tmp_string)); + Free(tmp_string); break; } } @@ -675,6 +678,7 @@ void SimpleType::referenceForCT(ComplexType * found_CT) { expstring_t tmp_string = mprintf("{%s:=\"%s\"}", field->Data->getName().convertedValue.c_str(), itemMisc->Data.c_str()); value.items_with_value.push_back(Mstring(tmp_string)); + Free(tmp_string); break; } } @@ -853,7 +857,7 @@ void SimpleType::printToFile(FILE * file) { void SimpleType::dump(unsigned int depth) const { static const char *modes[] = { - "", "restriction", "extension", "list" + "", "restriction", "extension", "list", "restrictionAfterList" }; fprintf(stderr, "%*s SimpleType '%s' -> '%s' at %p\n", depth * 2, "", name.originalValueWoPrefix.c_str(), name.convertedValue.c_str(), diff --git a/xsdconvert/TTCN3Module.cc b/xsdconvert/TTCN3Module.cc index 43ea435c95943886599c465078b27ed6c848a622..0f87339a0b8f2a5af8818be5caf684bbd978e434 100644 --- a/xsdconvert/TTCN3Module.cc +++ b/xsdconvert/TTCN3Module.cc @@ -333,7 +333,7 @@ void TTCN3Module::generate_with_statement(FILE * file, List<NamespaceType> used_ if (xsi) { fprintf(file, - " variant \"controlNamespace \'%s-instance\' prefix \'xsi\'\";\n", XMLSchema.c_str()); + " variant \"controlNamespace \'%s-instance\' prefix \'xsi\'\";\n", XMLSchema); } if (attributeFormDefault == qualified) { fprintf(file, diff --git a/xsdconvert/XMLParser.cc b/xsdconvert/XMLParser.cc index 9544034054c818d15f145f21ad9aff4991020b7c..821adcb7e34c0ce2b7f85a7ab5159419ccecfc39 100644 --- a/xsdconvert/XMLParser.cc +++ b/xsdconvert/XMLParser.cc @@ -350,7 +350,7 @@ void XMLParser::startelementHandler(const xmlChar * localname, } void XMLParser::startelementHandlerWhenXSDRead(const xmlChar * localname, - int nb_namespaces, const xmlChar ** namespaces, int nb_attributes, const xmlChar ** attributes) { + int /*nb_namespaces*/, const xmlChar ** /*namespaces*/, int /*nb_attributes*/, const xmlChar ** /*attributes*/) { if (strcmp((const char*)localname, "schema") == 0) { // Don't parse beyond the schema tag. xmlStopParser(contextCheckingXML); diff --git a/xsdconvert/converter.cc b/xsdconvert/converter.cc index f76709b06b431be3021ad3ab7b3dd00db9985fcb..c46aa7572e37f2df22020d82c56784328634b83b 100644 --- a/xsdconvert/converter.cc +++ b/xsdconvert/converter.cc @@ -54,7 +54,7 @@ static int checkSyntax(const bool not_verbose, const int first_module, const int const char * const * const module_names); static int validate(int const first_module, int const last_module, const char * const * const module_names); -static int get_xsd_module_names(const bool quiet, const int first_module, +static int get_xsd_module_names(const int first_module, const int last_module, const char * const * const module_names); static int generateCode(const bool quiet, const bool need_predefined, const int first_module, const int last_module, @@ -199,7 +199,7 @@ int main(int argc, char **argv) { } if (n_flag_used) { - get_xsd_module_names(q_flag_used, first_module, last_module, module_names); + get_xsd_module_names(first_module, last_module, module_names); return EXIT_SUCCESS; } @@ -216,6 +216,13 @@ int main(int argc, char **argv) { } return EXIT_FAILURE; } + + if (f_flag_used) { + for (int i = 0; i < last_module; ++i) { + Free(module_names[i]); + } + Free(module_names); + } if (XMLParser::getNumWarnings() > 0 || TTCN3ModuleInventory::getNumErrors() > 0 || @@ -389,7 +396,7 @@ static int checkSyntax(const bool not_verbose, const int first_module, const int return EXIT_SUCCESS; } -static int get_xsd_module_names(const bool quiet, const int first_module, +static int get_xsd_module_names(const int first_module, const int last_module, const char * const * const module_names) { TTCN3ModuleInventory& modules = TTCN3ModuleInventory::getInstance(); for (int i = first_module; i < last_module; ++i) {