diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace3_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace3_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..04529f02db172186227772241faba1c622763425 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace3_e.ttcn @@ -0,0 +1,77 @@ +/******************************************************************************* +* 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'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace_XmlTest_noTargetNamespace_1_xsd_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace_XmlTest_noTargetNamespace_1_xsd_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..64e6aa0a0b525d89076b412298727311e5041cbd --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace_XmlTest_noTargetNamespace_1_xsd_e.ttcn @@ -0,0 +1,58 @@ +/******************************************************************************* +* 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'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace_XmlTest_noTargetNamespace_2_xsd_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace_XmlTest_noTargetNamespace_2_xsd_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..b5b9c4e5960c371d9421dd665a689b109fa03f60 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace_XmlTest_noTargetNamespace_2_xsd_e.ttcn @@ -0,0 +1,60 @@ +/******************************************************************************* +* 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'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_xsds/XmlTest_noTargetNamespace_1.xsd b/regression_test/XML/XmlWorkflow/XmlTest_xsds/XmlTest_noTargetNamespace_1.xsd new file mode 100644 index 0000000000000000000000000000000000000000..3439efa9fb2e804cb55ec1fcc29309eea2b0b8ce --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_xsds/XmlTest_noTargetNamespace_1.xsd @@ -0,0 +1,17 @@ +<!-- + 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> diff --git a/regression_test/XML/XmlWorkflow/XmlTest_xsds/XmlTest_noTargetNamespace_2.xsd b/regression_test/XML/XmlWorkflow/XmlTest_xsds/XmlTest_noTargetNamespace_2.xsd new file mode 100644 index 0000000000000000000000000000000000000000..beaa77aa49164a11836ea56ac4f7f0f6f00da93f --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_xsds/XmlTest_noTargetNamespace_2.xsd @@ -0,0 +1,17 @@ +<!-- + 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> diff --git a/regression_test/XML/XmlWorkflow/src/xmlTest.prj b/regression_test/XML/XmlWorkflow/src/xmlTest.prj index d821e9e55de9c408fc5da06f028d89b6354d8fd5..ee09dcfe579eb581ffac7b9257124241073bd46b 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest.prj +++ b/regression_test/XML/XmlWorkflow/src/xmlTest.prj @@ -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" /> diff --git a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn index 38b19edb39300ac38b569cbf55581868e3ff8f4a..26ffe4b9da521c9d9d273a40e4455ce598f8c5db 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn +++ b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.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 { diff --git a/usrguide/referenceguide/9-xsd_to_ttcn-3_converter.adoc b/usrguide/referenceguide/9-xsd_to_ttcn-3_converter.adoc index ea394536bcbe0911ec5449374889b7fe6776c918..365888f39a5e7d424aa93aad7fa817dc817c3d09 100644 --- a/usrguide/referenceguide/9-xsd_to_ttcn-3_converter.adoc +++ b/usrguide/referenceguide/9-xsd_to_ttcn-3_converter.adoc @@ -30,7 +30,7 @@ An XML Schema is represented by a set of schema documents forming a complete spe The command line syntax of the converter is the following: [source] -xsd2ttcn [-ceghmopstVwx] [-f file] [-J file] schema.xsd [-schema.xsd…] +xsd2ttcn [-ceghmNopstVwx] [-f file] [-J file] schema.xsd [-schema.xsd…] or @@ -69,6 +69,10 @@ Instructs the converter to generate TTCN-3 code allowing type substitution. + Instructs the converter to only generate the `UsefulTtcn3Types` and `XSD` predefined modules. +* `-N` ++ +Instructs the converter to generate the definitions of XML schemas with no target namespaces into separate TTCN-3 modules (one module per XML schema). By default all definitions with no target namespace are generated into a single TTCN-3 module. + * `-o` + Generates all definitions into one module, called `XSD_Definitions`, instead of generating separate modules for each target namespace. The module contains one group for each target namespace. diff --git a/xsdconvert/TTCN3Module.cc b/xsdconvert/TTCN3Module.cc index afe81d3f433fae8363b661382f07f4fb240e9c8c..c2389736f16731c87308cef86837d32a589fe1f0 100644 --- a/xsdconvert/TTCN3Module.cc +++ b/xsdconvert/TTCN3Module.cc @@ -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; diff --git a/xsdconvert/converter.cc b/xsdconvert/converter.cc index 45f54e25bc898d9d6653674c0bc449d226cd3d6c..cb56175e22face65f51889992daf640278c51986 100644 --- a/xsdconvert/converter.cc +++ b/xsdconvert/converter.cc @@ -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" diff --git a/xsdconvert/converter.hh b/xsdconvert/converter.hh index e586dec353bf81de82b527cf69e9ec7d00b57a5a..0bf698a5369e75ed76a12b3ac03e7e037736a0d6 100644 --- a/xsdconvert/converter.hh +++ b/xsdconvert/converter.hh @@ -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;