Commit d7689306 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Added xsd2ttcn command line option to separate modules with no target namespace (bug 550942)



Change-Id: I10babb597640a08789eb8968ec33676d687ddf6b
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent 81e90f0b
/*******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom AB
*
* XSD to TTCN-3 Translator version: CRL 113 200/6 R6A
*
* 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: NoTargetNamespace.ttcn
// Description:
// References:
// Rev:
// Prodnr:
// Updated: Wed Sep 18 13:24:03 2019
// Contact: http://ttcn.ericsson.se
//
////////////////////////////////////////////////////////////////////////////////
// Generated from file(s):
// - XmlTest_noTargetNamespace_1.xsd
// /* xml version = "1.0" */
// /* targetnamespace = "NoTargetNamespace" */
// - XmlTest_noTargetNamespace_2.xsd
// /* xml version = "1.0" */
// /* targetnamespace = "NoTargetNamespace" */
////////////////////////////////////////////////////////////////////////////////
// Modification header(s):
//-----------------------------------------------------------------------------
// Modified by:
// Modification date:
// Description:
// Modification contact:
//------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
module NoTargetNamespace {
import from XSD all;
type XSD.Integer Type1
with {
variant "element";
};
type XSD.String Type2
with {
variant "element";
};
type XSD.String Type1_1
with {
variant "name as 'Type1'";
variant "element";
};
type XSD.Boolean Type2_1
with {
variant "name as 'Type2'";
variant "element";
//variant "text 'true' as '1'";
//variant "text 'false' as '0'";
};
}
with {
encode "XML";
variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'";
}
/*******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom AB
*
* XSD to TTCN-3 Translator version: CRL 113 200/6 R6A
*
* 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: NoTargetNamespace_XmlTest_noTargetNamespace_1_xsd.ttcn
// Description:
// References:
// Rev:
// Prodnr:
// Updated: Wed Sep 18 12:21:14 2019
// Contact: http://ttcn.ericsson.se
//
////////////////////////////////////////////////////////////////////////////////
// Generated from file(s):
// - XmlTest_noTargetNamespace_1.xsd
// /* xml version = "1.0" */
// /* targetnamespace = "NoTargetNamespace" */
////////////////////////////////////////////////////////////////////////////////
// Modification header(s):
//-----------------------------------------------------------------------------
// Modified by:
// Modification date:
// Description:
// Modification contact:
//------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
module NoTargetNamespace_XmlTest_noTargetNamespace_1_xsd {
import from XSD all;
type XSD.Integer Type1
with {
variant "element";
};
type XSD.String Type2
with {
variant "element";
};
}
with {
encode "XML";
variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'";
}
/*******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom AB
*
* XSD to TTCN-3 Translator version: CRL 113 200/6 R6A
*
* 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: NoTargetNamespace_XmlTest_noTargetNamespace_2_xsd.ttcn
// Description:
// References:
// Rev:
// Prodnr:
// Updated: Wed Sep 18 12:21:14 2019
// Contact: http://ttcn.ericsson.se
//
////////////////////////////////////////////////////////////////////////////////
// Generated from file(s):
// - XmlTest_noTargetNamespace_2.xsd
// /* xml version = "1.0" */
// /* targetnamespace = "NoTargetNamespace" */
////////////////////////////////////////////////////////////////////////////////
// Modification header(s):
//-----------------------------------------------------------------------------
// Modified by:
// Modification date:
// Description:
// Modification contact:
//------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
module NoTargetNamespace_XmlTest_noTargetNamespace_2_xsd {
import from XSD all;
type XSD.String Type1
with {
variant "element";
};
type XSD.Boolean Type2
with {
variant "element";
//variant "text 'true' as '1'";
//variant "text 'false' as '0'";
};
}
with {
encode "XML";
variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'";
}
<!--
Copyright (c) 2000-2019 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:
Botond, Baranyi
-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name='Type1' type='xsd:integer'/>
<xsd:element name='Type2' type='xsd:string'/>
</xsd:schema>
<!--
Copyright (c) 2000-2019 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:
Botond, Baranyi
-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name='Type1' type='xsd:string'/>
<xsd:element name='Type2' type='xsd:boolean'/>
</xsd:schema>
......@@ -264,6 +264,8 @@
<File path="../XmlTest_xsds/XmlTest_annotation1.xsd" />
<File path="../XmlTest_xsds/XmlTest_annotation2.xsd" />
<File path="../XmlTest_xsds/XmlTest_version.xsd" />
<File path="../XmlTest_xsds/XmlTest_noTargetNamespace_1.xsd" />
<File path="../XmlTest_xsds/XmlTest_noTargetNamespace_2.xsd" />
<File path="../XmlTest_xsds/XmlTest_files1.txt" />
</File_Group>
<File_Group name="expectedTtcns" >
......@@ -399,6 +401,9 @@
<File path="../XmlTest_expectedTtcns/XSD_Definitions_e.ttcn" />
<File path="../XmlTest_expectedTtcns/XSD_Definitions_e2.ttcn" />
<File path="../XmlTest_expectedTtcns/www_example_org_bug537922_e.ttcn" />
<File path="../XmlTest_expectedTtcns/NoTargetNamespace_XmlTest_noTargetNamespace_1_xsd_e.ttcn" />
<File path="../XmlTest_expectedTtcns/NoTargetNamespace_XmlTest_noTargetNamespace_2_xsd_e.ttcn" />
<File path="../XmlTest_expectedTtcns/NoTargetNamespace3_e.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" />
......
......@@ -2646,6 +2646,29 @@ group Elements{
"www_example_org_bug537922.ttcn", c_numOfDiff);
}
}
testcase tc_noTargetNamespace_separate() runs on xmlTest_CT { // bug 550942
f_shellCommandWithVerdict(xsd2ttcn_command & " -N XmlTest_noTargetNamespace_1.xsd XmlTest_noTargetNamespace_2.xsd", "", c_shell_successWithoutWarningAndError);
if(getverdict == pass) {
f_compareFiles(
"NoTargetNamespace_XmlTest_noTargetNamespace_1_xsd_e.ttcn",
"NoTargetNamespace_XmlTest_noTargetNamespace_1_xsd.ttcn", c_numOfDiff);
f_compareFiles(
"NoTargetNamespace_XmlTest_noTargetNamespace_2_xsd_e.ttcn",
"NoTargetNamespace_XmlTest_noTargetNamespace_2_xsd.ttcn", c_numOfDiff);
}
}
testcase tc_noTargetNamespace_merged() runs on xmlTest_CT { // bug 550942
f_shellCommandWithVerdict(xsd2ttcn_command & " XmlTest_noTargetNamespace_1.xsd XmlTest_noTargetNamespace_2.xsd", "", c_shell_successWithoutWarningAndError);
if(getverdict == pass) {
f_compareFiles(
"NoTargetNamespace3_e.ttcn",
"NoTargetNamespace.ttcn", c_numOfDiff);
}
}
}//Element
......@@ -2925,6 +2948,9 @@ control {
execute(tc_name_clashes_and_references_merged());
execute(tc_group_ref_order());
execute(tc_noTargetNamespace_separate());
execute(tc_noTargetNamespace_merged());
}
} with {
......
......@@ -369,6 +369,11 @@ void TTCN3Module::generate_with_statement(FILE * file, List<NamespaceType> used_
void TTCN3Module::TargetNamespace2ModuleName() {
Mstring res(targetNamespace);
if (N_flag_used && res == Mstring("NoTargetNamespace")) {
res += Mstring("_") + schemaname;
// TODO: delete '.xsd' or not? the standard CR is conflicted on this...
}
if (z_flag_used) {
char * found;
......
......@@ -38,6 +38,7 @@ bool g_flag_used = true;
bool h_flag_used = false;
bool m_flag_used = false;
bool n_flag_used = false; // Undocumented. Internal use only with makefilegen
bool N_flag_used = false;
bool o_flag_used = false;
bool p_flag_used = false;
bool s_flag_used = false;
......@@ -75,7 +76,7 @@ int main(int argc, char **argv) {
signed char c;
opterr = 0;
while ((c = getopt(argc, argv, "cdef:ghJ:mnopqstvwxz")) != -1) {
while ((c = getopt(argc, argv, "cdef:ghJ:mnNopqstvwxz")) != -1) {
switch (c) {
case 'c':
c_flag_used = true;
......@@ -103,6 +104,9 @@ int main(int argc, char **argv) {
case 'n':
n_flag_used = true;
break;
case 'N':
N_flag_used = true;
break;
case 'o':
o_flag_used = true;
break;
......@@ -258,6 +262,7 @@ static void printUsage(const char * argv0) {
" -g: generate TTCN-3 code disallowing element substitution\n"
" -h: generate TTCN-3 code allowing type substitution\n"
" -m: generate only the UsefulTtcn3Types and XSD predefined modules\n"
" -N: generate separate modules for each XSD with no target namespace\n"
" -o: generate all definitions into one module (called XSD_Definitions)\n"
" -p: do not generate the UsefulTtcn3Types and XSD predefined modules\n"
" -q: quiet mode - disable the issue of status messages\n"
......
......@@ -21,6 +21,7 @@ extern bool g_flag_used;
extern bool h_flag_used;
extern bool m_flag_used;
extern bool n_flag_used; // Undocumented. Internal use only with makefilegen
extern bool N_flag_used;
extern bool o_flag_used;
extern bool p_flag_used;
extern bool s_flag_used;
......
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