Commit 8879474a authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

xsd2ttcn: fixed sequence types with defaultforempty error (Bug 521796)



Change-Id: I1c5ff81f08417239bafb596f58fe83c8eb132ba4
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent ab5d9228
......@@ -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";
......
......@@ -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>
......@@ -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)) {
......
......@@ -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;
}
}
......
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