Commit b3b358af authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

xsd2ttcn: support enumeration restriction on sequence types (Bug 522177)



Change-Id: Icf0604f94e1ffc00ef818cc6acbeb4e8752ea9de
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent 22367622
......@@ -322,7 +322,7 @@ with {
};
/* Unsupported anytype and QName */
/* Unsupported anytype and QName and IDREFS and ENTITIES and NMTOKENS */
type XSD.AnyType AnyTypeDefault
......@@ -361,6 +361,30 @@ with {
};
type XSD.IDREFS IDREFSDefault
with {
variant "element";
};
type XSD.IDREFS IDREFSFixed
with {
variant "element";
};
type XSD.NMTOKENS NMTOKENSDefault
with {
variant "element";
};
type XSD.NMTOKENS NMTOKENSFixed
with {
variant "element";
};
/* Check if the name conversion follows to the constants too */
......
......@@ -116,6 +116,36 @@ with {
};
type enumerated NMTokens
{
vxmlcurrency,
vxmldate,
vxmldigits,
vxmlnumber,
vxmltime
}
with {
variant "text 'vxmlcurrency' as 'vxml:currency'";
variant "text 'vxmldate' as 'vxml:date'";
variant "text 'vxmldigits' as 'vxml:digits'";
variant "text 'vxmlnumber' as 'vxml:number'";
variant "text 'vxmltime' as 'vxml:time'";
};
type enumerated IDRefs
{
nmtokens_ref,
qname_ref
};
/* Still unsupported QName */
type XSD.QName QName;
}
with {
encode "XML";
......
......@@ -195,10 +195,26 @@ with {
};
type XSD.NMTOKENS NMTOKENSEnumeration;
type enumerated NMTOKENSEnumeration
{
false_,
true_
}
with {
variant "text 'false_' as 'false'";
variant "text 'true_' as 'true'";
};
type XSD.IDREFS IDREFSEnumeration;
type enumerated IDREFSEnumeration
{
false_,
true_
}
with {
variant "text 'false_' as 'false'";
variant "text 'true_' as 'true'";
};
type record Element
......
......@@ -1113,7 +1113,7 @@ group UnionTest {
testcase tc_enumeration_union_restriction() runs on xmlTest_CT {
f_shellCommandWithVerdict(xsd2ttcn_command & " enumeration_restriction.xsd","",c_shell_successWithWarning)
f_shellCommandWithVerdict(xsd2ttcn_command & " enumeration_restriction.xsd","",c_shell_successWithoutWarningAndError)
if(getverdict==pass) {
f_compareFiles(
......@@ -1135,7 +1135,7 @@ group UnionTest {
testcase tc_enumeration_restriction3() runs on xmlTest_CT {
f_shellCommandWithVerdict(xsd2ttcn_command & " enumeration_restriction3.xsd","",c_shell_successWithoutWarningAndError)
f_shellCommandWithVerdict(xsd2ttcn_command & " enumeration_restriction3.xsd","",c_shell_successWithWarning)
if(getverdict==pass) {
f_compareFiles(
......
......@@ -53,7 +53,7 @@
<xs:element name='AnySimpleTypeFixed' type="xs:anySimpleType" fixed='1.0.0'/>
<!-- Unsupported anytype and QName -->
<!-- Unsupported anytype and QName and IDREFS and ENTITIES and NMTOKENS -->
<xs:element name='AnyTypeDefault' default='1.0.0'/>
<xs:element name='AnyTypeFixed' fixed='1.0.0'/>
......@@ -66,6 +66,14 @@
<xs:element name='QNameFixed' type="xs:QName" fixed='Name'/>
<xs:element name='IDREFSDefault' type="xs:IDREFS" id="my_id" default='my_id'/>
<xs:element name='IDREFSFixed' type="xs:IDREFS" fixed='my_id'/>
<xs:element name='NMTOKENSDefault' type="xs:NMTOKENS" default='abc'/>
<xs:element name='NMTOKENSFixed' type="xs:NMTOKENS" fixed='abc'/>
<!-- Check if the name conversion follows to the constants too -->
<xs:element name="AttrfixedMyString3_"/>
<xs:element name="MyString_"/>
......
......@@ -52,5 +52,33 @@
</simpleContent>
</complexType>
<simpleType name="NMTokens" id="nmtokens_ref">
<restriction base="NMTOKENS">
<enumeration value="vxml:digits"/>
<enumeration value="vxml:number"/>
<enumeration value="vxml:time"/>
<enumeration value="vxml:date"/>
<enumeration value="vxml:currency"/>
</restriction>
</simpleType>
<simpleType name="IDRefs">
<restriction base="IDREFS">
<enumeration value="nmtokens_ref"/>
<enumeration value="qname_ref"/>
</restriction>
</simpleType>
<!-- Still unsupported QName -->
<simpleType name="QName" id="qname_ref">
<restriction base="QName">
<enumeration value="digits"/>
<enumeration value="number"/>
<enumeration value="time"/>
<enumeration value="date"/>
<enumeration value="currency"/>
</restriction>
</simpleType>
</schema>
......@@ -1267,7 +1267,7 @@ void EnumerationType::applyFacets() // string types, integer types, float types,
const Mstring & base = parent->getBuiltInBase();
if (isStringType(base)) // here length restriction is applicable
if (isStringType(base) || (isSequenceType(base) && base != "QName")) // here length restriction is applicable
{
List<Mstring> text_variants;
for (List<Mstring>::iterator facet = facets.begin(); facet; facet = facet->Next) {
......@@ -1370,7 +1370,7 @@ void EnumerationType::printToFile(FILE * file, unsigned int indent_level) const
if (!modified) return;
const Mstring & base = parent->getBuiltInBase();
if (isStringType(base)) {
if (isStringType(base) || (isSequenceType(base) && base != "QName")) {
for (QualifiedNames::iterator itemString = items_string.begin(); itemString; itemString = itemString->Next) {
if (itemString != items_string.begin()) fputs(",\n", file);
for (unsigned int l = 0; l != indent_level; ++l) fputs("\t", file);
......@@ -1634,8 +1634,8 @@ void ValueType::printToFile(FILE * file) const {
if(!isBuiltInType(type)){
type = findBuiltInType(parent, type);
}
const Mstring& name = type.getValueWithoutPrefix(':');
if (isStringType(type) || isTimeType(type) || isQNameType(type) || isAnyType(type)) {
const Mstring& name = type.getValueWithoutPrefix(':');
if (name != "hexBinary" && name != "base64Binary") {
fprintf(file, " (\"%s\")", fixed_value.c_str());
}
......@@ -1652,7 +1652,7 @@ void ValueType::printToFile(FILE * file) const {
} else if (isFloatType(type)) {
Mstring val = xmlFloat2TTCN3FloatStr(fixed_value);
fprintf(file, " (%s)", val.c_str());
} else {
} else if (name != "NMTOKENS" && name != "IDREFS" && name != "ENTITIES"){
fprintf(file, " (%s)", fixed_value.c_str());
}
}
......
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