diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_simpletype_base_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_simpletype_base_e.ttcn index 3d740be927d5f4d86434876dd9e85f307c1ba8fd..ab3aa14696c6fce4ec0734e92c89916a411212eb 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_simpletype_base_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_simpletype_base_e.ttcn @@ -44,14 +44,22 @@ module www_example_org_simpletype_base { import from XSD all; -type record SimpleTypebase +type enumerated Isknown { - enumerated { - unknown - } base + known, + unknown } with { - variant (base) "untagged"; + variant "name as uncapitalized"; +}; + + +type enumerated SimpleTypebase +{ + unknown +} +with { + variant "element"; }; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_xsds/XmlTest_string.xsd b/regression_test/XML/XmlWorkflow/XmlTest_xsds/XmlTest_string.xsd index 658ae929193a54004751aa7fa8ab39f6f92b7b80..b3d1e0547e602fa420a87fbf3c81bd31c8430f8d 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_xsds/XmlTest_string.xsd +++ b/regression_test/XML/XmlWorkflow/XmlTest_xsds/XmlTest_string.xsd @@ -25,7 +25,7 @@ </xsd:documentation> </xsd:annotation> -<xsd:element name="NameA" type="Name"/> +<xsd:element name="NameA" type="strng:Name"/> <xsd:simpleType name="Name"> <xsd:restriction base="xsd:string"> diff --git a/regression_test/XML/XmlWorkflow/xsd/attribgroup_ingroup.xsd b/regression_test/XML/XmlWorkflow/xsd/attribgroup_ingroup.xsd index 6ccede2df052202df01767296fb71e3c9648da0f..f02d2cd913114eb2c2632dba02980510dc4504b1 100644 --- a/regression_test/XML/XmlWorkflow/xsd/attribgroup_ingroup.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/attribgroup_ingroup.xsd @@ -7,7 +7,7 @@ <xsd:attributeGroup ref="this:AttributeGroup"/> </xsd:complexType> -<xsd:attribute name="remoteSchema" type="anyURI"> +<xsd:attribute name="remoteSchema" type="xsd:anyURI"> </xsd:attribute> <xsd:attributeGroup name="AttributeGroup"> @@ -16,7 +16,7 @@ </xsd:attributeGroup> <xsd:attributeGroup name="simpleLink"> - <xsd:attribute name="type" type="string" fixed="simple" form="qualified"/> + <xsd:attribute name="type" type="xsd:string" fixed="simple" form="qualified"/> </xsd:attributeGroup> </xsd:schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/attribute_in_extension.xsd b/regression_test/XML/XmlWorkflow/xsd/attribute_in_extension.xsd index de0baf90b3e078395283feed4ac8a16d936ebeca..4b6f9dfaedbd89ac08859174333d54ccf2269d45 100644 --- a/regression_test/XML/XmlWorkflow/xsd/attribute_in_extension.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/attribute_in_extension.xsd @@ -4,7 +4,7 @@ xmlns:ns45="attribute_in_extension" targetNamespace="attribute_in_extension" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:complexType name="BaseType"> <xs:sequence> - <xs:element name="Base-variable" type="integer" nillable="false"> + <xs:element name="Base-variable" type="xs:integer" nillable="false"> </xs:element> </xs:sequence> </xs:complexType> @@ -14,7 +14,7 @@ targetNamespace="attribute_in_extension" elementFormDefault="qualified" attribut <xs:complexType> <xs:complexContent> <xs:extension base="ns45:BaseType"> - <xs:attribute name="extension" type="integer"> + <xs:attribute name="extension" type="xs:integer"> </xs:attribute> </xs:extension> </xs:complexContent> diff --git a/regression_test/XML/XmlWorkflow/xsd/imported2.xsd b/regression_test/XML/XmlWorkflow/xsd/imported2.xsd index 5229db6886b54294d1865183ef9118a13c9f123c..3755b5f83e6b65fb9be9d0aae6509337c54170fc 100644 --- a/regression_test/XML/XmlWorkflow/xsd/imported2.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/imported2.xsd @@ -3,17 +3,17 @@ targetNamespace="www.example.org/imported2"> <xsd:simpleType name="foobar"> - <xsd:restriction base="integer"/> + <xsd:restriction base="xsd:integer"/> </xsd:simpleType> <xsd:simpleType name="ding"> - <xsd:restriction base="integer"/> + <xsd:restriction base="xsd:integer"/> </xsd:simpleType> <xsd:element name="bar"> <xsd:complexType> <xsd:sequence> - <xsd:element name="something" type="string" minOccurs="0"/> + <xsd:element name="something" type="xsd:string" minOccurs="0"/> </xsd:sequence> </xsd:complexType> </xsd:element> diff --git a/regression_test/XML/XmlWorkflow/xsd/imported_prefix_name.xsd b/regression_test/XML/XmlWorkflow/xsd/imported_prefix_name.xsd index 03df4768add4b2f3d113f3647dc8851c7b85fa4b..e2748a4bd6478846f01bd3e51ed55510fbd6cb91 100644 --- a/regression_test/XML/XmlWorkflow/xsd/imported_prefix_name.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/imported_prefix_name.xsd @@ -3,17 +3,17 @@ targetNamespace="www.example.org/imported"> <xsd:simpleType name="foobar"> - <xsd:restriction base="integer"/> + <xsd:restriction base="xsd:integer"/> </xsd:simpleType> <xsd:simpleType name="ding"> - <xsd:restriction base="integer"/> + <xsd:restriction base="xsd:integer"/> </xsd:simpleType> <xsd:element name="bar"> <xsd:complexType> <xsd:sequence> - <xsd:element name="something" type="string" minOccurs="0"/> + <xsd:element name="something" type="xsd:string" minOccurs="0"/> </xsd:sequence> </xsd:complexType> </xsd:element> diff --git a/regression_test/XML/XmlWorkflow/xsd/namespaceas.xsd b/regression_test/XML/XmlWorkflow/xsd/namespaceas.xsd index 2887ce8d097f7d58a1851874c39c90c5af3e791a..a6d9e9103bdcc12120a9409b6a9caef9993fe2be 100644 --- a/regression_test/XML/XmlWorkflow/xsd/namespaceas.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/namespaceas.xsd @@ -49,7 +49,9 @@ <xsd:complexType> <xsd:complexContent> <xsd:restriction base="other:bar"> - <xsd:element name="something" type="string" minOccurs="1"/> + <xsd:sequence> + <xsd:element name="something" type="string" minOccurs="1"/> + </xsd:sequence> </xsd:restriction> </xsd:complexContent> </xsd:complexType> diff --git a/regression_test/XML/XmlWorkflow/xsd/no_ns_connector.xsd b/regression_test/XML/XmlWorkflow/xsd/no_ns_connector.xsd index d834536fc45a97dc6856cdacbe380e4a1d3794a1..55d1fd36c74ebe9e87a634fac7aa16b42b7b57b2 100644 --- a/regression_test/XML/XmlWorkflow/xsd/no_ns_connector.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/no_ns_connector.xsd @@ -7,7 +7,7 @@ <xsd:complexType name="java-attribute" abstract="true"> <xsd:attribute name="java-attribute" type="xsd:string"/> - <xsd:attribute name="xml-accessor-type" type="string"/> + <xsd:attribute name="xml-accessor-type" type="xsd:string"/> </xsd:complexType> </xsd:schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/simpletype_base.xsd b/regression_test/XML/XmlWorkflow/xsd/simpletype_base.xsd index 0ceade97a3f48c221d13c4cbe5b3ff8b75a8bf2c..fe86a272d113920b7049932104fc74416fcd3e20 100644 --- a/regression_test/XML/XmlWorkflow/xsd/simpletype_base.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/simpletype_base.xsd @@ -3,13 +3,20 @@ xmlns:this="www.example.org/simpletype/base" targetNamespace="www.example.org/simpletype/base"> -<xsd:complexType name="SimpleTypebase"> - <xsd:simpleContent> - <xsd:restriction base="string"> +<xsd:simpleType name="isknown"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="known"/> + <xsd:enumeration value="unknown"/> + </xsd:restriction> +</xsd:simpleType> + +<xsd:element name="SimpleTypebase"> + <xsd:simpleType> + <xsd:restriction base="this:isknown"> <xsd:enumeration value="unknown" /> </xsd:restriction> - </xsd:simpleContent> -</xsd:complexType> + </xsd:simpleType> +</xsd:element> </xsd:schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_main.xsd b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_main.xsd index cf7600bdee344e2acfa73cf42482f24735e0222c..f61318c7d6238cb9d11f6d0215a1f0f4c5d9f9d6 100644 --- a/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_main.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_main.xsd @@ -4,7 +4,7 @@ <xsd:import namespace="www.example.org/substitutiongroup/ref"/> -<xsd:element name="subsgroup" type="string" abstract="true" /> +<xsd:element name="subsgroup" type="xsd:string" abstract="true" /> <xsd:element name="refgroup" type="A:subsgroup" /> diff --git a/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_ref.xsd b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_ref.xsd index 4a7084f1db090d5d3b7fc23aa72e5c98d044bd7d..171099146286338a32192a6600b06497b1831c69 100644 --- a/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_ref.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_ref.xsd @@ -6,7 +6,7 @@ <xsd:import namespace="www.example.org/substitutiongroup/main"/> -<xsd:element name="replace" type="string" substitutionGroup="A:subsgroup"/> +<xsd:element name="replace" type="xsd:string" substitutionGroup="A:subsgroup"/> </xsd:schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_rename.xsd b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_rename.xsd index 41f3f3c911ce309a6a0ebf607a3832c1d57b2316..ba3583fba4133586e451d6fb5248818f2a6f3d6d 100644 --- a/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_rename.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_rename.xsd @@ -18,9 +18,9 @@ </xsd:complexContent> </xsd:complexType> -<xsd:element name="Case" type="integer" abstract="true"/> +<xsd:element name="Case" type="xsd:integer" abstract="true"/> -<xsd:element name="BaseElement__" type="string" abstract="true"/> +<xsd:element name="BaseElement__" type="xsd:string" abstract="true"/> <xsd:element name="BaseElement" type="this:BaseElement_" abstract="true"/> diff --git a/regression_test/XML/XmlWorkflow/xsd/type_substitution_complex_cascade.xsd b/regression_test/XML/XmlWorkflow/xsd/type_substitution_complex_cascade.xsd index 6260ae20c1a2d9d0a9430b0c5a8413679b83f107..b11055aead67f578d517c854e13fb6d3fb578e67 100644 --- a/regression_test/XML/XmlWorkflow/xsd/type_substitution_complex_cascade.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/type_substitution_complex_cascade.xsd @@ -5,8 +5,8 @@ <xsd:element name="request" type="requestType" /> -<xsd:element name="myProductionRequestType_" type="string" /> -<xsd:element name="myProductionRequestType2_" type="string" /> +<xsd:element name="myProductionRequestType_" type="xsd:string" /> +<xsd:element name="myProductionRequestType2_" type="xsd:string" /> <!-- The generic base type --> <xsd:complexType name="requestType"> diff --git a/regression_test/XML/XmlWorkflow/xsd/type_substitution_mod2.xsd b/regression_test/XML/XmlWorkflow/xsd/type_substitution_mod2.xsd index f0c63361d18fdbcc280d164c8feae55f5812cf4d..291134f6b2c3edab76e2c12339826a55bb447ba3 100644 --- a/regression_test/XML/XmlWorkflow/xsd/type_substitution_mod2.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/type_substitution_mod2.xsd @@ -11,7 +11,7 @@ <xsd:extension base="A:ParentType"> <xsd:sequence> </xsd:sequence> - <xsd:attribute name="attr1" type="string" /> + <xsd:attribute name="attr1" type="xsd:string" /> </xsd:extension> </xsd:complexContent> </xsd:complexType> @@ -23,7 +23,7 @@ <xsd:element name="foo" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/> <xsd:element name="bar" type="xsd:string"/> </xsd:sequence> - <xsd:attribute name="attr1" type="string" use="prohibited" /> + <xsd:attribute name="attr1" type="xsd:string" use="prohibited" /> </xsd:restriction> </xsd:complexContent> </xsd:complexType> diff --git a/regression_test/XML/XmlWorkflow/xsd/type_substitution_simple_cascade.xsd b/regression_test/XML/XmlWorkflow/xsd/type_substitution_simple_cascade.xsd index b2d36de5331ac014edd28c483f1fa3476bfcf7a7..3ad882471fa93f0d6dc1c958b872b1ddb20a17c3 100644 --- a/regression_test/XML/XmlWorkflow/xsd/type_substitution_simple_cascade.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/type_substitution_simple_cascade.xsd @@ -3,13 +3,13 @@ targetNamespace="www.example.org/type/substitution/simple/cascade" xmlns="www.example.org/type/substitution/simple/cascade"> -<xsd:element name="elem" type="string"/> +<xsd:element name="elem" type="xsd:string"/> <xsd:element name="elem1" type="stringtype"/> <xsd:element name="elem2" type="stringtype2"/> <xsd:element name="elem3" type="stringtype3"/> <xsd:simpleType name="stringtype"> - <xsd:restriction base="string"/> + <xsd:restriction base="xsd:string"/> </xsd:simpleType> <xsd:simpleType name="stringtype2"> diff --git a/regression_test/XML/xsdConverter/HO21968/HO21968noprefix.xsd b/regression_test/XML/xsdConverter/HO21968/HO21968noprefix.xsd index 130cfe3753e443b6c7048dbd3f3f38cbfa571353..4341cb2102e3b25e00df95a34b0439c803383728 100644 --- a/regression_test/XML/xsdConverter/HO21968/HO21968noprefix.xsd +++ b/regression_test/XML/xsdConverter/HO21968/HO21968noprefix.xsd @@ -17,7 +17,7 @@ <xs:complexType name="MySeq"> <xs:sequence> - <xs:element name="i" type="integer" minOccurs="0" maxOccurs="unbounded"/> + <xs:element name="i" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> diff --git a/regression_test/XML/xsdConverter/HO21968/HO21968prefix.xsd b/regression_test/XML/xsdConverter/HO21968/HO21968prefix.xsd index 616aadb9bbce452e5c81e5a78a8a51416a0af622..a93230b4bd31c53a76f6953519c05e0edc0e4796 100644 --- a/regression_test/XML/xsdConverter/HO21968/HO21968prefix.xsd +++ b/regression_test/XML/xsdConverter/HO21968/HO21968prefix.xsd @@ -17,7 +17,7 @@ <xs:complexType name="MySeqPrefix"> <xs:sequence> - <xs:element name="i" type="integer" minOccurs="0" maxOccurs="unbounded"/> + <xs:element name="i" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> diff --git a/xsdconvert/ComplexType.cc b/xsdconvert/ComplexType.cc index 9e0ddb9e5a21acc1e1956742d4110a1776237fbc..fcfa384cba59aff2d1a846b34f2ba21501d40185 100644 --- a/xsdconvert/ComplexType.cc +++ b/xsdconvert/ComplexType.cc @@ -160,20 +160,20 @@ ComplexType::ComplexType(const SimpleType & other, CT_fromST c) switch (c) { case fromTagUnion: - type.upload(Mstring("union")); + type.upload(Mstring("union"), false); with_union = true; xsdtype = n_union; break; case fromTagNillable: addVariant(V_useNil); - type.upload(Mstring("record")); + type.upload(Mstring("record"), false); break; case fromTagComplexType: - type.upload(Mstring("record")); + type.upload(Mstring("record"), false); xsdtype = n_complexType; break; case fromTagSubstitution: - type.upload(Mstring("union")); + type.upload(Mstring("union"), false); name.upload(getName().originalValueWoPrefix + Mstring("_group")); xsdtype = n_union; subsGroup = this; @@ -186,7 +186,7 @@ ComplexType::ComplexType(const SimpleType & other, CT_fromST c) whitespace.modified = false; break; case fromTypeSubstitution: - type.upload(Mstring("union")); + type.upload(Mstring("union"), false); name.upload(getName().originalValueWoPrefix + Mstring("_derivations")); xsdtype = n_union; substitutionGroup = empty_string; @@ -229,7 +229,7 @@ void ComplexType::loadWithValues() { if (!top && xsdtype != n_sequence && xsdtype != n_complexType && xsdtype != n_extension && xsdtype != n_restriction && xsdtype != n_element) { //Create new record ComplexType * rec = new ComplexType(this); - rec->type.upload(Mstring("record")); + rec->type.upload(Mstring("record"), false); rec->name.upload(Mstring("sequence")); rec->addVariant(V_untagged); rec->setMinMaxOccurs(atts.minOccurs, atts.maxOccurs); @@ -241,7 +241,7 @@ void ComplexType::loadWithValues() { if (xsdtype == n_sequence && atts.minOccurs == 1 && atts.maxOccurs == 1) { skipback += 1; } - type.upload(Mstring("record")); + type.upload(Mstring("record"), false); xsdtype = n_sequence; setMinMaxOccurs(atts.minOccurs, atts.maxOccurs); } @@ -250,7 +250,7 @@ void ComplexType::loadWithValues() { if (!top || xsdtype != n_group) { //Create new union field ComplexType * choice = new ComplexType(this); - choice->type.upload(Mstring("union")); + choice->type.upload(Mstring("union"), false); choice->name.upload(Mstring("choice")); choice->setXsdtype(n_choice); choice->addVariant(V_untagged); @@ -259,7 +259,7 @@ void ComplexType::loadWithValues() { complexfields.push_back(choice); } else { xsdtype = n_choice; - type.upload(Mstring("union")); + type.upload(Mstring("union"), false); } break; case n_all: @@ -332,7 +332,7 @@ void ComplexType::loadWithValues() { //If a simple top level element is nillable ComplexType * nilrec = new ComplexType(this); if (atts.type.empty()) { - nilrec->type.upload(Mstring("record")); + nilrec->type.upload(Mstring("record"), false); } else { nilrec->type.upload(atts.type); } @@ -341,7 +341,7 @@ void ComplexType::loadWithValues() { nilrec->nillable = true; setMinMaxOccurs(atts.minOccurs, atts.maxOccurs); complexfields.push_back(nilrec); - type.upload(Mstring("record")); + type.upload(Mstring("record"), false); name.upload(atts.name); actfield = nilrec; nillable_field = nilrec; @@ -350,12 +350,12 @@ void ComplexType::loadWithValues() { ComplexType * record = new ComplexType(this); ComplexType * nilrec = new ComplexType(record); if (atts.type.empty()) { - nilrec->type.upload(Mstring("record")); + nilrec->type.upload(Mstring("record"), false); } else { nilrec->type.upload(atts.type); } record->name.upload(atts.name); - record->type.upload(Mstring("record")); + record->type.upload(Mstring("record"), false); record->complexfields.push_back(nilrec); record->addVariant(V_useNil); record->nillable_field = nilrec; @@ -451,7 +451,7 @@ void ComplexType::loadWithValues() { { ComplexType * any = new ComplexType(this); any->name.upload(Mstring("elem")); - any->type.upload(Mstring("xsd:string")); + any->type.upload(Mstring("string"), false); any->applyNamespaceAttribute(V_anyElement, atts.namespace_); any->setMinMaxOccurs(atts.minOccurs, atts.maxOccurs); any->setXsdtype(n_any); @@ -463,7 +463,7 @@ void ComplexType::loadWithValues() { AttributeType * anyattr = new AttributeType(this); anyattr->setXsdtype(n_anyAttribute); anyattr->setNameOfField(Mstring("attr")); - anyattr->setTypeValue(Mstring("xsd:string")); + anyattr->setTypeValue(Mstring("string")); anyattr->setToAnyAttribute(); anyattr->applyMinMaxOccursAttribute(0, ULLONG_MAX); anyattr->addNameSpaceAttribute(atts.namespace_); @@ -516,7 +516,7 @@ void ComplexType::loadWithValues() { { with_union = true; xsdtype = n_union; - type.upload(Mstring("union")); + type.upload(Mstring("union"), false); addVariant(V_useUnion); if (!atts.memberTypes.empty()) { List<Mstring> types; @@ -567,7 +567,7 @@ void ComplexType::loadWithValues() { } case n_complexType: name.upload(atts.name); - type.upload(Mstring("record")); + type.upload(Mstring("record"), false); applyAbstractAttribute(atts.abstract); applySubstitionGroupAttribute(atts.substitionGroup); applyBlockAttribute(atts.block); @@ -578,7 +578,7 @@ void ComplexType::loadWithValues() { if (atts.mixed) { ComplexType * mixed = new ComplexType(this); mixed->name.upload(Mstring("embed_values")); - mixed->type.upload(Mstring("xsd:string")); + mixed->type.upload(Mstring("string"), false); mixed->setMinMaxOccurs(0, ULLONG_MAX, false); mixed->embed = true; complexfields.push_back(mixed); @@ -1411,7 +1411,7 @@ void ComplexType::setMinMaxOccurs(const unsigned long long min, const unsigned l first_child = false; } else if (xsdtype == n_sequence) { ComplexType * rec = new ComplexType(this); - rec->type.upload(Mstring("record")); + rec->type.upload(Mstring("record"), false); rec->name.upload(Mstring("sequence")); rec->setXsdtype(n_sequence); rec->addVariant(V_untagged); diff --git a/xsdconvert/GeneralFunctions.cc b/xsdconvert/GeneralFunctions.cc index d0c6e85e197c68f14bc85509946380b5d74f89b0..4d1b7215988f80ba9bcc32c02d2266a3729d8418 100644 --- a/xsdconvert/GeneralFunctions.cc +++ b/xsdconvert/GeneralFunctions.cc @@ -519,7 +519,7 @@ bool matchDates(const char * string, const char * type) { const Mstring second("([0-5][0-9])"); const Mstring endofdayext("24:00:00(.0?)?"); const Mstring yearext("((-)([1-9][0-9]*)?)?"); - const Mstring timezone("(Z|[+-]((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"); + const Mstring time_zone("(Z|[+-]((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"); const Mstring fraction("(.[0-9]+)?"); const Mstring nums("[0-9]+"); const Mstring durtime("(T[0-9]+" @@ -528,24 +528,24 @@ bool matchDates(const char * string, const char * type) { Mstring pattern; if (strcmp(type, "gDay") == 0) { - pattern = Mstring("(---)") + day + timezone; + pattern = Mstring("(---)") + day + time_zone; } else if (strcmp(type, "gMonth") == 0) { - pattern = Mstring("(--)") + month + timezone; + pattern = Mstring("(--)") + month + time_zone; } else if (strcmp(type, "gYear") == 0) { - pattern = yearext + year + timezone; + pattern = yearext + year + time_zone; } else if (strcmp(type, "gYearMonth") == 0) { - pattern = yearext + year + Mstring("(-)") + month + timezone; + pattern = yearext + year + Mstring("(-)") + month + time_zone; } else if (strcmp(type, "gMonthDay") == 0) { - pattern = Mstring("(--)") + month + Mstring("(-)") + day + timezone; + pattern = Mstring("(--)") + month + Mstring("(-)") + day + time_zone; } else if (strcmp(type, "date") == 0) { - pattern = yearext + year + Mstring("(-)") + month + Mstring("(-)") + day + timezone; + pattern = yearext + year + Mstring("(-)") + month + Mstring("(-)") + day + time_zone; } else if (strcmp(type, "time") == 0) { pattern = Mstring("(") + hour + Mstring(":") + minute + Mstring(":") + second + - fraction + Mstring("|") + endofdayext + Mstring(")") + timezone; + fraction + Mstring("|") + endofdayext + Mstring(")") + time_zone; } else if (strcmp(type, "dateTime") == 0) { pattern = yearext + year + Mstring("(-)") + month + Mstring("(-)") + day + Mstring("T(") + hour + Mstring(":") + minute + Mstring(":") + second + - fraction + Mstring("|") + endofdayext + Mstring(")") + timezone; + fraction + Mstring("|") + endofdayext + Mstring(")") + time_zone; } else if (strcmp(type, "duration") == 0) { pattern = Mstring("(-)?P(") + nums + Mstring("(Y(") + nums + Mstring("(M(") + nums + Mstring("D") + durtime + Mstring("?|") + durtime + Mstring("?|D") + diff --git a/xsdconvert/ImportStatement.cc b/xsdconvert/ImportStatement.cc index c72d7d47fb8e02e0b723c6632a9c1e38775aff21..71511146f19f0d49f17e0820e672e2c11de5f80d 100644 --- a/xsdconvert/ImportStatement.cc +++ b/xsdconvert/ImportStatement.cc @@ -31,13 +31,13 @@ void ImportStatement::loadWithValues() { switch (parser->getActualTagName()) { case n_import: name.upload(Mstring("import")); - type.upload(Mstring("import")); + type.upload(Mstring("import"), false); from_namespace = attr.namespace_; from_schemaLocation = attr.schemaLocation; break; case n_include: name.upload(Mstring("include")); - type.upload(Mstring("include")); + type.upload(Mstring("include"), false); from_namespace = attr.namespace_; from_schemaLocation = attr.schemaLocation; break; diff --git a/xsdconvert/RootType.cc b/xsdconvert/RootType.cc index 19a768b92b06801f5a69f59573be5ec23c0d464d..86eb146c3b3c7a51e9c781e903355e7dfc298875 100644 --- a/xsdconvert/RootType.cc +++ b/xsdconvert/RootType.cc @@ -20,7 +20,7 @@ RootType::RootType(XMLParser * a_parser, TTCN3Module * a_module, const Construct : parser(a_parser) , module(a_module) , name() -, type() +, type(a_module, a_parser) , variant() , variant_ref() , comment() @@ -42,30 +42,30 @@ RootType::RootType(XMLParser * a_parser, TTCN3Module * a_module, const Construct case c_unknown: // because when using fields in complextypes we set construct to c_unknown case c_simpleType: origin = from_simpleType; - type.upload(Mstring("anySimpleType")); + type.upload(Mstring("anySimpleType"), false); break; case c_element: origin = from_element; - type.upload(Mstring("anyType")); + type.upload(Mstring("anyType"), false); addVariant(V_element); break; case c_attribute: origin = from_attribute; - type.upload(Mstring("anySimpleType")); + type.upload(Mstring("anySimpleType"), false); addVariant(V_attribute); break; case c_complexType: origin = from_complexType; - type.upload(Mstring("record")); + type.upload(Mstring("record"), false); break; case c_group: origin = from_group; - type.upload(Mstring("record")); + type.upload(Mstring("record"), false); addVariant(V_untagged); break; case c_attributeGroup: origin = from_attributeGroup; - type.upload(Mstring("record")); + type.upload(Mstring("record"), false); addVariant(V_attributeGroup); visible = false; break; diff --git a/xsdconvert/RootType.hh b/xsdconvert/RootType.hh index 9026d4dd4a033063c777cb4957798a0a9a00caf9..7574136de6dd4a20de51d294abe518298e3f174a 100644 --- a/xsdconvert/RootType.hh +++ b/xsdconvert/RootType.hh @@ -15,8 +15,11 @@ #define BASETYPE_HH_ #include "GeneralTypes.hh" +#include "GeneralFunctions.hh" #include "Mstring.hh" #include "List.hh" +#include "TTCN3Module.hh" +#include "XMLParser.hh" #include <cmath> // for using "pow" function #include <cfloat> @@ -93,10 +96,64 @@ public: } }; -class SimpleType; -class XMLParser; -class TTCN3Module; +class TypeType { +public: + const TTCN3Module * const t_module; // Not owned + const XMLParser * t_parser; // Not owned + Mstring originalValueWoPrefix; + Mstring convertedValue; + Mstring refPrefix; + bool list_extension; + bool no_replace; + + TypeType(const TTCN3Module * const module, const XMLParser * parser) : + t_module(module), + t_parser(parser), + originalValueWoPrefix(), + convertedValue(), + refPrefix(), + list_extension(false), + no_replace(false) + {} + // Default copy constructor, assignment operator and destructor are used + + void upload(const Mstring& input, bool prefixCheck = true) { + if (input.empty()) return; + convertedValue = input; + originalValueWoPrefix = input.getValueWithoutPrefix(':'); + if (isBuiltInType(input)) { + refPrefix = input.getPrefix(':'); + if (prefixCheck) { + checkBuintInTypeReference(); + } + } + } + + void checkBuintInTypeReference() { + bool found = false; + for (List<Mstring>::iterator px = t_module->getxmlSchemaPrefixes().begin(); px; px = px->Next) { + if (refPrefix == px->Data) { + found = true; + break; + } + } + // Second chance. It may be a prefix from one of the xsd-s. + if (!found) { + for (List<NamespaceType>::iterator ns = t_module->getDeclaredNamespaces().begin(); ns; ns = ns->Next) { + if (refPrefix == ns->Data.prefix.c_str()) { + found = true; + break; + } + } + } + if (!found) { + printError(t_module->getSchemaname(), t_parser->getActualLineNumber(), Mstring("Cannot find the namespace of type: ") + originalValueWoPrefix); + t_parser->incrNumErrors(); + } +} +}; +class SimpleType; /** * This type is used as the base class for the used classes * that represent the main datatypes in the generated TTCN-3 modules @@ -111,7 +168,7 @@ protected: TTCN3Module * module; // no responsibility for this member NameType name; - NameType type; + TypeType type; List<Mstring> variant; List<Mstring> variant_ref; List<Mstring> hidden_variant; @@ -202,7 +259,7 @@ public: return name; } - const NameType & getType() const { + const TypeType & getType() const { return type; } diff --git a/xsdconvert/SimpleType.cc b/xsdconvert/SimpleType.cc index fa3a7fdc6a44986c741a206960e4934d948fc4d8..6a277e2f371b1fb6639eca0467e8b5afcb8f3d3f 100644 --- a/xsdconvert/SimpleType.cc +++ b/xsdconvert/SimpleType.cc @@ -488,10 +488,19 @@ void SimpleType::setReference(const Mstring& ref, bool only_name_dependency) { name.upload(ref); } if (type.convertedValue.empty() || type.convertedValue == "anySimpleType") { - type.upload(ref.getValueWithoutPrefix(':')); + type.upload(ref); + } + bool found = false; + for (List<NamespaceType>::iterator ns = getModule()->getDeclaredNamespaces().begin(); ns; ns = ns->Next) { + if (ns->Data.uri != XMLSchema && type.refPrefix == ns->Data.prefix.c_str()) { + found = true; + break; + } } fromRef = true; - return; + if (!found) { + return; + } } Mstring refPrefix = ref.getPrefix(':'); @@ -547,7 +556,7 @@ void SimpleType::referenceResolving() { } if(outside_reference.empty() && substitutionGroup.empty()) return; if (outside_reference.is_resolved()) return; - + if(!outside_reference.empty()){ SimpleType * found_ST = static_cast<SimpleType*> ( TTCN3ModuleInventory::getInstance().lookup(this, want_ST)); @@ -587,20 +596,19 @@ void SimpleType::referenceResolving() { void SimpleType::referenceForST(SimpleType * found_ST) { outside_reference.set_resolved(found_ST); - if (in_name_only) return; + if (!found_ST->builtInBase.empty()) { + builtInBase = found_ST->builtInBase; + } + if (construct == c_element) return; if (mode == listMode || mode == restrictionAfterListMode) return; - if (!found_ST->builtInBase.empty()) { - builtInBase = found_ST->builtInBase; - } - length.applyReference(found_ST->length); pattern.applyReference(found_ST->pattern); enumeration.applyReference(found_ST->enumeration); diff --git a/xsdconvert/SimpleType.hh b/xsdconvert/SimpleType.hh index dc893650292b61b444aa521195187dc29fd017d9..4318fedc341f1379e33428c42ab70f0bcae9cf31 100644 --- a/xsdconvert/SimpleType.hh +++ b/xsdconvert/SimpleType.hh @@ -381,8 +381,8 @@ public: return block; } - void setList(const bool value) { - inList = value; + void setList(const bool list) { + inList = list; } void addToNameDepList(SimpleType * t) { diff --git a/xsdconvert/TTCN3Module.cc b/xsdconvert/TTCN3Module.cc index cb1df1f1bfcf733b1b2948ffe263a87e0e92215f..43ea435c95943886599c465078b27ed6c848a622 100644 --- a/xsdconvert/TTCN3Module.cc +++ b/xsdconvert/TTCN3Module.cc @@ -53,6 +53,7 @@ TTCN3Module::TTCN3Module(const char * a_filename, XMLParser * a_parser) , element_types() //, importedModules() , variant() +, xmlSchemaPrefixes() , moduleNotIntoFile(false) , moduleNotIntoNameConversion(false) { #if defined(WIN32) && !defined(MINGW) @@ -120,6 +121,15 @@ void TTCN3Module::loadValuesFromSchemaTag(const Mstring& a_targetNamespace, break; } } + + for (List<NamespaceType>::iterator ns = declaredNamespaces.begin(); ns; ns = ns->Next) { + if (ns->Data.uri == XMLSchema) { + Mstring prefix = ns->Data.prefix; + prefix.removeWSfromBegin(); + prefix.removeWSfromEnd(); + xmlSchemaPrefixes.push_back(prefix); + } + } } void TTCN3Module::addMainType(const ConstructType typeOfMainType) { diff --git a/xsdconvert/TTCN3Module.hh b/xsdconvert/TTCN3Module.hh index 60989267b6913c842509062818e6f0765f4bac31..aec34860daa19794e2dce31d49c78b6a3085d53b 100644 --- a/xsdconvert/TTCN3Module.hh +++ b/xsdconvert/TTCN3Module.hh @@ -87,6 +87,8 @@ class TTCN3Module { List<typeNameDepList> element_types; List<Mstring> variant; + + List<Mstring> xmlSchemaPrefixes; bool moduleNotIntoFile; bool moduleNotIntoNameConversion; @@ -223,6 +225,10 @@ public: List<typeNameDepList> & getElementTypes() { return element_types; } + + const List<Mstring> & getxmlSchemaPrefixes() const { + return xmlSchemaPrefixes; + } void addElementType(const Mstring& type, SimpleType* st) { List<typeNameDepList>::iterator it = element_types.begin();