Commit 61ea2d40 authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

xsd2ttcn: another fix with lists



Change-Id: I6db196a6963a4f9111400ab68086d1077b664c38
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent 708b3930
......@@ -128,6 +128,25 @@ with {
};
type union MyType
{
XSD.Boolean alt_,
record of XSD.Integer alt_1,
record of XSD.Float alt_2
}
with {
variant "useUnion";
variant "element";
variant (alt_) "name as ''";
//variant (alt_) "text 'true' as '1'";
//variant (alt_) "text 'false' as '0'";
variant (alt_1) "list";
variant (alt_1) "name as ''";
variant (alt_2) "list";
variant (alt_2) "name as ''";
};
}
with {
encode "XML";
......
......@@ -111,6 +111,22 @@
</xsd:simpleType>
</xsd:element>
<xsd:element name="MyType">
<xsd:simpleType>
<xsd:union>
<xsd:simpleType>
<xsd:restriction base="boolean" />
</xsd:simpleType>
<xsd:simpleType>
<xsd:list itemType="integer" />
</xsd:simpleType>
<xsd:simpleType>
<xsd:list itemType="float" />
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>
</xsd:element>
</xsd:schema>
......@@ -587,7 +587,6 @@ void ComplexType::loadWithValues() {
break;
case n_list:
if (parent != NULL && parent->basefield == this) {
parent->inList = true;
parent->SimpleType::loadWithValues();
parent->basefield = NULL;
setInvisible();
......@@ -662,6 +661,17 @@ void ComplexType::modifyValues() {
}
}
void ComplexType::modifyList() {
if (this != actfield) {
((SimpleType*)actfield)->modifyList();
return;
}
if (!inList && mode == listMode && parent != NULL) {
parent->actfield = parent;
parent->lastType = xsdtype;
}
}
void ComplexType::referenceResolving() {
if (resolved != No) return; // nothing to do
if(this == subsGroup){
......
......@@ -141,6 +141,7 @@ public:
void nameConversion(NameConversionMode mode, const List<NamespaceType> & ns);
void finalModification();
bool hasUnresolvedReference(){ return resolved == No; }
void modifyList();
void setNameDep(SimpleType * dep) { nameDep = dep; }
void setParentTypeSubsGroup(ComplexType * dep) { parentTypeSubsGroup = dep; }
......
......@@ -793,6 +793,10 @@ bool SimpleType::hasUnresolvedReference() {
}
}
void SimpleType::modifyList() {
// Intentional empty
}
void SimpleType::applyRefAttribute(const Mstring& ref_value) {
if (!ref_value.empty()) {
setReference(ref_value);
......
......@@ -278,6 +278,7 @@ public:
void nameConversion(const NameConversionMode mode, const List<NamespaceType> & ns);
void finalModification();
virtual bool hasUnresolvedReference();
virtual void modifyList();
void dump(const unsigned int depth) const;
void applyDefaultAttribute(const Mstring& default_value);
......
......@@ -54,7 +54,8 @@ XMLParser::XMLParser(const char * a_filename)
, actualTagName(n_NOTSET)
, actualTagAttributes(this)
, parentTagNames()
, inside_annotation(){
, inside_annotation()
, lastWasListEnd(false){
xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader);
parserCheckingXML = (xmlSAXHandler *) malloc(sizeof (xmlSAXHandler));
......@@ -302,9 +303,13 @@ void XMLParser::startelementHandler(const xmlChar * localname,
default:
if (module->hasDefinedMainType()) {
if(actualTagName == n_annotation ||
actualTagName == n_appinfo ||
actualTagName == n_documentation){
if (lastWasListEnd) {
((SimpleType&)(module->getLastMainType())).modifyList();
lastWasListEnd = false;
}
if(actualTagName == n_annotation ||
actualTagName == n_appinfo ||
actualTagName == n_documentation){
inside_annotation.push_back(actualTagName);
module->getLastMainType().loadWithValues();
}else if(inside_annotation.empty()){
......@@ -323,6 +328,9 @@ void XMLParser::startelementHandler(const xmlChar * localname,
++actualDepth;
parentTagNames.push_back(actualTagName);
if (lastWasListEnd) {
lastWasListEnd = false;
}
}
void XMLParser::endelementHandler(const xmlChar * localname) {
......@@ -355,12 +363,15 @@ void XMLParser::endelementHandler(const xmlChar * localname) {
}
if(tag == n_list) {
if(module->hasDefinedMainType()) {
SimpleType& st = (SimpleType&)(module->getLastMainType());
if(st.getXsdtype() == n_NOTSET){
st.setMode(SimpleType::restrictionAfterListMode);
}
lastWasListEnd = true;
if(module->hasDefinedMainType()) {
SimpleType& st = (SimpleType&)(module->getLastMainType());
if(st.getXsdtype() == n_NOTSET){
st.setMode(SimpleType::restrictionAfterListMode);
}
}
} else if (tag != n_simpleType){
lastWasListEnd = false;
}
--actualDepth;
......
......@@ -172,6 +172,8 @@ private:
// Stack for keeping track if we are inside an annotation tag
List<TagName> inside_annotation;
bool lastWasListEnd;
static bool suspended;
......
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