Commit 1d589791 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

xsd2ttcn: fixed name clashes and references in merged module (bug 541748)



Change-Id: If3e2313bcdf2eed8440c525bd2c562e7cd421929
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent f24f81c7
/*******************************************************************************
* Copyright (c) 2000-2018 Ericsson Telecom AB
*
* XSD to TTCN-3 Translator version: CRL 113 200/6 R5A
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*******************************************************************************/
//
// File: XSD_Definitions.ttcn
// Description:
// References:
// Rev:
// Prodnr:
// Updated: Mon Dec 10 16:18:41 2018
// Contact: http://ttcn.ericsson.se
//
////////////////////////////////////////////////////////////////////////////////
// Modification header(s):
//-----------------------------------------------------------------------------
// Modified by:
// Modification date:
// Description:
// Modification contact:
//------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
module XSD_Definitions {
import from XSD all;
////////////////////////////////////////////////////////////////////////////////
// Generated from file(s):
// - name_clashes_and_references_A.xsd
// /* xml version = "1.0" encoding = "UTF-8" */
// /* targetnamespace = "http://somewhere.com/A" */
////////////////////////////////////////////////////////////////////////////////
group http_somewhere_com_A {
import from XSD all;
const XSD.String c_defaultForEmpty_1 := "1.0.0";
type record ComplexType
{
XSD.String version (c_defaultForEmpty_1) optional,
record of XSD.String field_list
}
with {
variant (version) "defaultForEmpty as c_defaultForEmpty_1";
variant (version) "name as capitalized";
variant (version) "attribute";
variant (field_list) "untagged";
variant (field_list[-]) "name as 'Field'";
};
type XSD.String SimpleType;
}
with {
encode "XML";
variant "namespace as 'http://somewhere.com/A'";
variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'";
variant "elementFormQualified";
}
////////////////////////////////////////////////////////////////////////////////
// Generated from file(s):
// - name_clashes_and_references_B.xsd
// /* xml version = "1.0" encoding = "UTF-8" */
// /* targetnamespace = "http://somewhere.com/B" */
////////////////////////////////////////////////////////////////////////////////
group http_somewhere_com_B {
import from XSD all;
const XSD.String c_defaultForEmpty_2 := "abc";
type ComplexType ComplexType_1
with {
variant "name as 'ComplexType'";
variant "element";
};
type XSD.Integer SimpleType_1
with {
variant "name as 'SimpleType'";
};
type record ComplexType_2
{
XSD.String version (c_defaultForEmpty_1) optional,
record length(1 .. infinity) of XSD.String field_list (c_defaultForEmpty_2)
}
with {
variant "name as 'ComplexType'";
variant (version) "defaultForEmpty as c_defaultForEmpty_1";
variant (version) "name as capitalized";
variant (version) "attribute";
variant (field_list[-]) "defaultForEmpty as c_defaultForEmpty_2";
variant (field_list) "untagged";
variant (field_list[-]) "name as 'Field'";
};
type record Other
{
SimpleType attrib optional,
ComplexType field
}
with {
variant (attrib) "name as capitalized";
variant (attrib) "attribute";
variant (field) "name as capitalized";
};
}
with {
encode "XML";
variant "namespace as 'http://somewhere.com/B'";
variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'";
variant "elementFormQualified";
}
}
......@@ -8,6 +8,7 @@
Contributors:
Balasko, Jeno
Baranyi, Botond
Ormandi, Matyas
Raduly, Csaba
Szabo, Bence Janos
......@@ -146,6 +147,8 @@
<File path="../xsd/substitutiongroup_ref.xsd" />
<File path="../xsd/substitution_group_one.xsd" />
<File path="../xsd/substitution_group_two.xsd" />
<File path="../xsd/name_clashes_and_references_A.xsd" />
<File path="../xsd/name_clashes_and_references_B.xsd" />
<File path="../xsd/simpletype_base.xsd" />
<File path="../xsd/type_substitution.xsd" />
<File path="../xsd/type_substitution_chain.xsd" />
......@@ -392,6 +395,7 @@
<File path="../XmlTest_expectedTtcns/www_example_org_substitutiongroup_ref_e.ttcn" />
<File path="../XmlTest_expectedTtcns/www_example_org_substitutiongroup_main_e.ttcn" />
<File path="../XmlTest_expectedTtcns/XSD_Definitions_e.ttcn" />
<File path="../XmlTest_expectedTtcns/XSD_Definitions_e2.ttcn" />
<File path="../XmlTest_expectedTtcns/www_example_org_simpletype_base_e.ttcn" />
<File path="../XmlTest_expectedTtcns/www_example_org_type_substitution_e.ttcn" />
<File path="../XmlTest_expectedTtcns/www_example_org_type_substitution_chain_e.ttcn" />
......
......@@ -2625,6 +2625,17 @@ group Elements{
"XSD_Definitions.ttcn", c_numOfDiff);
}
}
testcase tc_name_clashes_and_references_merged() runs on xmlTest_CT { // bug 541748
f_shellCommandWithVerdict(xsd2ttcn_command & " -o name_clashes_and_references_A.xsd name_clashes_and_references_B.xsd",
"", c_shell_successWithoutWarningAndError);
if(getverdict == pass) {
f_compareFiles(
"XSD_Definitions_e2.ttcn",
"XSD_Definitions.ttcn", c_numOfDiff);
}
}
}//Element
......@@ -2901,6 +2912,7 @@ control {
execute(tc_element_nillable_RemarkNillable_nilTrue_encDec());
execute(tc_substitution_group_merged());
execute(tc_name_clashes_and_references_merged());
}
} with {
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2000-2018 Ericsson Telecom AB
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
Contributors:
Baranyi, Botond
-->
<xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema" xmlns = "http://somewhere.com/A" targetNamespace = "http://somewhere.com/A" elementFormDefault = "qualified" version = "1.0">
<xsd:complexType name = "ComplexType">
<xsd:sequence>
<xsd:element name = "Field" type = "xsd:string" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name = "Version" type = "xsd:string" fixed="1.0.0"/>
</xsd:complexType>
<xsd:simpleType name = "SimpleType">
<xsd:restriction base = "xsd:string"/>
</xsd:simpleType>
</xsd:schema>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2000-2018 Ericsson Telecom AB
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
Contributors:
Baranyi, Botond
-->
<xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema" xmlns:a = "http://somewhere.com/A" xmlns = "http://somewhere.com/B" targetNamespace = "http://somewhere.com/B" elementFormDefault = "qualified" version = "1.0">
<xsd:import namespace="http://somewhere.com/A" schemaLocation="name_clashes_and_references_A.xsd"/>
<xsd:element name = "ComplexType" type = "a:ComplexType"/>
<xsd:simpleType name = "SimpleType">
<xsd:restriction base = "xsd:integer"/>
</xsd:simpleType>
<xsd:complexType name = "ComplexType">
<xsd:complexContent>
<xsd:restriction base="a:ComplexType">
<xsd:sequence>
<xsd:element name = "Field" type = "xsd:string" minOccurs="1" maxOccurs="unbounded" fixed="abc"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name = "Other">
<xsd:sequence>
<xsd:element name = "Field" type = "a:ComplexType"/>
</xsd:sequence>
<xsd:attribute name = "Attrib" type = "a:SimpleType"/>
</xsd:complexType>
</xsd:schema>
......@@ -237,7 +237,7 @@ void AttributeType::printToFile(FILE* file, unsigned level) {
}else {
printMinOccursMaxOccurs(file, false);
int multiplicity = multi(module, getReference(), this);
if ((multiplicity > 1) && getReference().get_ref()) {
if (!o_flag_used && (multiplicity > 1) && getReference().get_ref()) {
fprintf(file, "%s.", getReference().get_ref()->getModule()->getModulename().c_str());
}
fprintf(file, "%s %s", type.convertedValue.c_str(), name.convertedValue.c_str());
......
......@@ -1258,7 +1258,7 @@ void ComplexType::printToFile(FILE * file, const unsigned level, const bool is_u
}
} else {
int multiplicity = multi(module, getReference(), this);
if ((multiplicity > 1) && getReference().get_ref()) {
if (!o_flag_used && (multiplicity > 1) && getReference().get_ref()) {
fprintf(file, "%s.", getReference().get_ref()->getModule()->getModulename().c_str());
}
if (field_is_record || field_is_union || listPrint) {
......
......@@ -205,7 +205,7 @@ Mstring Constant::getConstantName(const TTCN3Module* other_mod) const {
} else {
qname = getName().convertedValue;
}
if (other_mod->getModulename() != getModule()->getModulename()) {
if (!o_flag_used && other_mod->getModulename() != getModule()->getModulename()) {
qname = getModule()->getModulename() + "." + qname;
}
return qname;
......
......@@ -265,7 +265,8 @@ void XSDName2TTCN3Name(const Mstring& in_str, const Mstring& in_namespace,
}
for (QualifiedNames::iterator used = used_names.begin(); used; used = used->Next) {
if (qual_name == used->Data) {
if ((!o_flag_used && qual_name == used->Data) ||
(o_flag_used && qual_name.name == used->Data.name)) {
postfixing = true;
break;
}
......
......@@ -933,8 +933,9 @@ void SimpleType::printToFile(FILE * file) {
int multiplicity = multi(module, outside_reference, this);
const RootType *type_ref = outside_reference.get_ref();
if ((multiplicity > 1 && type_ref && type_ref->getModule() != module)
|| name.convertedValue == type.convertedValue) {
if (!o_flag_used &&
((multiplicity > 1 && type_ref && type_ref->getModule() != module)
|| name.convertedValue == type.convertedValue)) {
fprintf(file, "%s.", type_ref->getModule()->getModulename().c_str());
}
......
......@@ -213,7 +213,9 @@ void TTCN3ModuleInventory::nameConversion() {
for (List<RootType*>::iterator type = definedGroups_inABC.begin(); type; type = type->Next) {
type->Data->nameConversion(nameMode, module->Data->getDeclaredNamespaces());
}
typenames.clear();
if (!o_flag_used) {
typenames.clear();
}
}
/********************************************************
* Conversion of the type of types
......
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