Commit 09357332 authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

xsd2ttcn: fixed nillable content field nameconversion follow (Bug 526921)



Change-Id: I59e35d66685dfff210e162e5577fd4213c813a9a
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent ef931e65
/******************************************************************************
* 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'";
}
......@@ -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" />
......
......@@ -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());
......
<?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>
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment