From aeb2e5bb0a09c29375aff17abf011e471200744a Mon Sep 17 00:00:00 2001 From: BenceJanosSzabo <bence.janos.szabo@ericsson.com> Date: Thu, 26 Oct 2017 14:36:52 +0200 Subject: [PATCH] xsd2ttcn: allow defaultForEmpty for enumerated restricted NMTOKENS, IDREFS (Bug 526506) Change-Id: I6904cf27e05126fe33e45aab4bea4dc347bfecce Signed-off-by: BenceJanosSzabo <bence.janos.szabo@ericsson.com> --- ...example_org_enumeration_restriction_e.ttcn | 68 +++++++++++++++++++ .../xsd/enumeration_restriction.xsd | 32 +++++++++ xsdconvert/Constant.cc | 7 +- 3 files changed, 105 insertions(+), 2 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 ef57f20dc..9c9ce5ed1 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 @@ -44,6 +44,18 @@ module www_example_org_enumeration_restriction { import from XSD all; +const NMTOKENSEnumeration c_defaultForEmpty_1 := false_; + + +const IDREFSEnumeration c_defaultForEmpty_2 := false_; + + +const NMTOKENSEnumType c_defaultForEmpty_3 := false_; + + +const IDREFSEnumType c_defaultForEmpty_4 := false_; + + type E21unnamed_type E21unnamed with { variant "name as uncapitalized"; @@ -224,11 +236,67 @@ type record Element } with { variant "element"; + variant (modal) "defaultForEmpty as c_defaultForEmpty_1"; variant (modal) "attribute"; + variant (modal2) "defaultForEmpty as c_defaultForEmpty_2"; variant (modal2) "attribute"; }; +type NMTOKENSEnumType NMTOKENSEnumElem +with { + variant "defaultForEmpty as c_defaultForEmpty_3"; + variant "element"; +}; + + +type enumerated NMTOKENSEnumType +{ + false_, + true_ +} +with { + variant "text 'false_' as 'false'"; + variant "text 'true_' as 'true'"; +}; + + +type NMTOKENSType NMTOKENSElem +with { + variant "element"; +}; + + +type XSD.NMTOKENS NMTOKENSType; + + +type IDREFSEnumType IDREFSEnumElem +with { + variant "defaultForEmpty as c_defaultForEmpty_4"; + variant "element"; +}; + + +type enumerated IDREFSEnumType +{ + false_, + true_ +} +with { + variant "text 'false_' as 'false'"; + variant "text 'true_' as 'true'"; +}; + + +type IDREFSType IDREFSElem +with { + variant "element"; +}; + + +type XSD.IDREFS IDREFSType; + + } with { encode "XML"; diff --git a/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd b/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd index 5b5d0bdf1..eb02f88b7 100644 --- a/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/enumeration_restriction.xsd @@ -167,4 +167,36 @@ </xs:complexType> </xs:element> + +<xs:element name="NMTOKENSEnumElem" type="this:NMTOKENSEnumType" default="false"/> + +<xs:simpleType name="NMTOKENSEnumType"> + <xs:restriction base="xs:NMTOKENS"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> +</xs:simpleType> + +<xs:element name="NMTOKENSElem" type="this:NMTOKENSType" default="false"/> + +<xs:simpleType name="NMTOKENSType"> + <xs:restriction base="xs:NMTOKENS"/> +</xs:simpleType> + + +<xs:element name="IDREFSEnumElem" type="this:IDREFSEnumType" default="false"/> + +<xs:simpleType name="IDREFSEnumType"> + <xs:restriction base="xs:IDREFS"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> +</xs:simpleType> + +<xs:element name="IDREFSElem" type="this:IDREFSType" default="false"/> + +<xs:simpleType name="IDREFSType"> + <xs:restriction base="xs:IDREFS"/> +</xs:simpleType> + </xs:schema> diff --git a/xsdconvert/Constant.cc b/xsdconvert/Constant.cc index 29fa165b9..211783027 100644 --- a/xsdconvert/Constant.cc +++ b/xsdconvert/Constant.cc @@ -108,8 +108,11 @@ void Constant::finalModification() { type.upload(newtype); } - // Theese types do not support enumeration restriction - if (tmp_type == "NMTOKENS" || tmp_type == "IDREFS" || tmp_type == "ENTITIES") { + // These types do not support enumeration restriction + if (!(parent->getEnumeration().modified || + (parent->getReference().get_ref() != NULL && + ((SimpleType*)(parent->getReference().get_ref()))->getEnumeration().modified)) + && (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 = ""; -- GitLab