From 8879474a56258400b6ad0b5c95622451a01c6ce8 Mon Sep 17 00:00:00 2001 From: BenceJanosSzabo <bence.janos.szabo@ericsson.com> Date: Tue, 5 Sep 2017 11:13:06 +0200 Subject: [PATCH] xsd2ttcn: fixed sequence types with defaultforempty error (Bug 521796) Change-Id: I1c5ff81f08417239bafb596f58fe83c8eb132ba4 Signed-off-by: BenceJanosSzabo <bence.janos.szabo@ericsson.com> --- ...example_org_enumeration_restriction_e.ttcn | 18 ++++++++++++++ .../xsd/enumeration_restriction.xsd | 24 +++++++++++++++++++ xsdconvert/Constant.cc | 13 ++++++++-- xsdconvert/SimpleType.cc | 6 ++--- 4 files changed, 56 insertions(+), 5 deletions(-) diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction_e.ttcn index 17de22b46..1ef6eb34d 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_enumeration_restriction_e.ttcn @@ -174,6 +174,24 @@ with { }; +type XSD.NMTOKENS NMTOKENSEnumeration; + + +type XSD.IDREFS IDREFSEnumeration; + + +type record Element +{ + NMTOKENSEnumeration modal optional, + IDREFSEnumeration modal2 optional +} +with { + variant "element"; + variant (modal) "attribute"; + variant (modal2) "attribute"; +}; + + } with { encode "XML"; diff --git a/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd b/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd index 64720a207..cbde162ce 100644 --- a/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd @@ -144,4 +144,28 @@ </xs:simpleType> </xs:element> + +<xs:simpleType name="NMTOKENSEnumeration"> + <xs:restriction base="xs:NMTOKENS"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> +</xs:simpleType> + +<xs:simpleType name="IDREFSEnumeration"> + <xs:restriction base="xs:IDREFS"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> +</xs:simpleType> + +<xs:element name="Element"> + <xs:complexType> + <xs:sequence> + </xs:sequence> + <xs:attribute name="modal" type="this:NMTOKENSEnumeration" default="false"/> + <xs:attribute name="modal2" type="this:IDREFSEnumeration" default="false"/> +</xs:complexType> +</xs:element> + </xs:schema> diff --git a/xsdconvert/Constant.cc b/xsdconvert/Constant.cc index 2c085e2a6..29fa165b9 100644 --- a/xsdconvert/Constant.cc +++ b/xsdconvert/Constant.cc @@ -108,8 +108,16 @@ void Constant::finalModification() { type.upload(newtype); } - // String and time types need the quote character around the value - if (parent->getEnumeration().modified || + // Theese types do not support enumeration restriction + if (tmp_type == "NMTOKENS" || tmp_type == "IDREFS" || tmp_type == "ENTITIES") { + // These are not supported by TITAN. + // Reset the default value and fixed value + parent->getValue().default_value = ""; + parent->getValue().fixed_value = ""; + unsupported = true; + // Set the constant to invisible so it won't be generated into the code. + setInvisible(); + } else if (parent->getEnumeration().modified || (parent->getReference().get_ref() != NULL && ((SimpleType*)(parent->getReference().get_ref()))->getEnumeration().modified)) { @@ -136,6 +144,7 @@ void Constant::finalModification() { j++; } } + // String and time types need the quote character around the value } else if (isStringType(tmp_type) || isTimeType(tmp_type) || tmp_type == "anySimpleType") { value = Mstring("\"") + value + Mstring("\""); } else if (isFloatType(tmp_type)) { diff --git a/xsdconvert/SimpleType.cc b/xsdconvert/SimpleType.cc index f3c896f9e..83397ab92 100644 --- a/xsdconvert/SimpleType.cc +++ b/xsdconvert/SimpleType.cc @@ -266,7 +266,7 @@ void SimpleType::applyDefaultAttribute(const Mstring& default_value) { value.default_value = default_value; const Mstring typeT = type.originalValueWoPrefix.getValueWithoutPrefix(':'); //Not supported for hexBinary and base64Binary - if (typeT != "hexBinary" && typeT != "base64Binary") { + if (typeT != "hexBinary" && typeT != "base64Binary" && typeT != "NMTOKENS" && typeT != "IDREFS" && typeT != "ENTITIES") { Constant * c = new Constant(this, type.convertedValue, default_value); module->addConstant(c); defaultForEmptyConstant = c; @@ -282,7 +282,7 @@ void SimpleType::applyFixedAttribute(const Mstring& fixed_value) { value.modified = true; const Mstring typeT = type.originalValueWoPrefix.getValueWithoutPrefix(':'); //Not supported for hexBinary and base64Binary - if (typeT != "hexBinary" && typeT != "base64Binary") { + if (typeT != "hexBinary" && typeT != "base64Binary" && typeT != "NMTOKENS" && typeT != "IDREFS" && typeT != "ENTITIES") { Constant * c = new Constant(this, type.convertedValue, fixed_value); module->addConstant(c); defaultForEmptyConstant = c; @@ -1344,7 +1344,7 @@ void EnumerationType::applyFacets() // string types, integer types, float types, printWarning(parent->getModule()->getSchemaname(), parent->getName().convertedValue, Mstring("Enumeration restriction is not supported on type '") + base + Mstring("'.")); TTCN3ModuleInventory::getInstance().incrNumWarnings(); - parent->setInvisible(); + modified = false; } } -- GitLab