diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_nillable_nameconversion_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_nillable_nameconversion_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..ee41358578196e87e74bb55cad4b11f2d65090ec --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_nillable_nameconversion_e.ttcn @@ -0,0 +1,94 @@ +/****************************************************************************** +* Copyright (c) 2000-2017 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator +* +* 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_nillable_nameconversion.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Thu Aug 1 13:47:14 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - nillable_nameconversion.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/nillable/nameconversion" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_nillable_nameconversion { + + +import from XSD all; + + +type record ListOfUInt16_1 +{ + record of XSD.UnsignedShort uInt16_list +} +with { + variant "name as 'ListOfUInt16'"; + variant (uInt16_list) "untagged"; + variant (uInt16_list[-]) "name as 'UInt16'"; +}; + + +type record ListOfUInt16 +{ + ListOfUInt16_1 content optional +} +with { + variant "useNil"; + variant "element"; +}; + + +type record ListOfUIntType +{ + record { + ListOfUInt16_1 content optional + } listOfUInt16 +} +with { + variant (listOfUInt16) "name as capitalized"; + variant (listOfUInt16) "useNil"; +}; + + +type record Int32 +{ + XSD.Int content optional +} +with { + variant "useNil"; + variant "element"; +}; + + +} +with { + encode "XML"; + variant "namespace as 'www.example.org/nillable/nameconversion' prefix 'n'"; + 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 a5993898f577835538a8b1f6431fd995d71cdf4b..ff8f45f9442073c3398ded205f62ac2baf3c14a4 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest.prj +++ b/regression_test/XML/XmlWorkflow/src/xmlTest.prj @@ -178,6 +178,7 @@ <File path="../xsd/defaultforempty_same_ns1.xsd" /> <File path="../xsd/defaultforempty_same_ns2.xsd" /> <File path="../xsd/correct_ref_and_type.xsd" /> + <File path="../xsd/nillable_nameconversion.xsd" /> </File_Group> <File_Group name="XmlTest_xsds" > <File path="../XmlTest_xsds/XmlTest_boolean.xsd" /> @@ -428,6 +429,7 @@ <File path="../XmlTest_expectedTtcns/www_example_org_defaultforempty_mod2_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_defaultforempty_same_ns_e.ttcn" /> <File path="../XmlTest_expectedTtcns/http_www_example_org_correct_ref_and_type_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_nillable_nameconversion_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 59f8c9b1081a062f41fc7108491a6e9e34ccc9c2..4c4387d29bfac5aba98adaeb4f4a8264dd9e82c4 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn +++ b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn @@ -1580,6 +1580,16 @@ group ComplexType { } }//tc_ + testcase tc_nillable_nameconversion() runs on xmlTest_CT { + f_shellCommandWithVerdict(xsd2ttcn_command & " nillable_nameconversion.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_nillable_nameconversion_e.ttcn", + "www_example_org_nillable_nameconversion.ttcn", c_numOfDiff); + } + }//tc_ + //Fixed or defaultforempty attribute is not allowed on nillable elements according to TITAN testcase tc_nillable_fixed() runs on xmlTest_CT { f_shellCommandWithVerdict(xsd2ttcn_command & " nillable_fixed.xsd","",c_shell_successWithoutWarningAndError) @@ -2769,6 +2779,7 @@ control { execute(tc_complex_restriction_converter()); //Failed, TR HL32896 execute(tc_complex_restriction_with_use()); execute(tc_complex_nillable()); + execute(tc_nillable_nameconversion()); execute(tc_nillable_fixed()); execute(tc_no_ns_connector()); execute(tc_xmlschema()); diff --git a/regression_test/XML/XmlWorkflow/xsd/nillable_nameconversion.xsd b/regression_test/XML/XmlWorkflow/xsd/nillable_nameconversion.xsd new file mode 100644 index 0000000000000000000000000000000000000000..ee5fe7c9aca04ab3e406606be2d5a176aa1e51cf --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/nillable_nameconversion.xsd @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:n="www.example.org/nillable/nameconversion" + targetNamespace="www.example.org/nillable/nameconversion"> + + + <xsd:complexType name="ListOfUInt16"> + <xsd:sequence> + <xsd:element name="UInt16" type="xsd:unsignedShort" minOccurs="0" maxOccurs="unbounded" /> + </xsd:sequence> + </xsd:complexType> + + + <xsd:element name="ListOfUInt16" type="n:ListOfUInt16" nillable="true"></xsd:element> + + <xsd:complexType name="ListOfUIntType"> + <xsd:sequence> + <xsd:element name="ListOfUInt16" type="n:ListOfUInt16" nillable="true"></xsd:element> + </xsd:sequence> + </xsd:complexType> + + <xsd:element name="Int32" nillable="true" type="xsd:int" /> + +</xsd:schema> diff --git a/xsdconvert/ComplexType.cc b/xsdconvert/ComplexType.cc index f0b025d8f4b12e9ff8863515f5322bef0b4dd304..f6871b07a683f5f7cf74d95e75bc06384c1640f0 100644 --- a/xsdconvert/ComplexType.cc +++ b/xsdconvert/ComplexType.cc @@ -344,10 +344,12 @@ void ComplexType::loadWithValues() { if(cmode == CT_simpletype_mode){ //If a simple top level element is nillable ComplexType * nilrec = new ComplexType(this); + nilrec->xsdtype = n_element; if (atts.type.empty()) { nilrec->type.upload(Mstring("record"), false); } else { nilrec->type.upload(atts.type); + nilrec->setReference(atts.type); } nilrec->name.upload(Mstring("content")); nilrec->isOptional = true; @@ -362,10 +364,12 @@ void ComplexType::loadWithValues() { //From a complexType element is nillable ComplexType * record = new ComplexType(this); ComplexType * nilrec = new ComplexType(record); + nilrec->xsdtype = n_element; if (atts.type.empty()) { nilrec->type.upload(Mstring("record"), false); } else { nilrec->type.upload(atts.type); + nilrec->setReference(atts.type); } record->name.upload(atts.name); record->type.upload(Mstring("record"), false);