Commit c5deaf48 authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

Implemented Check when importing from an XSD Schema that the correct prefix is used (Bug 506144 )



Change-Id: I1ff8495f1964c317261d42c1afba664dc8a763a0
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent 1cc18f23
......@@ -44,14 +44,22 @@ module www_example_org_simpletype_base {
import from XSD all;
type record SimpleTypebase
type enumerated Isknown
{
enumerated {
unknown
} base
known,
unknown
}
with {
variant (base) "untagged";
variant "name as uncapitalized";
};
type enumerated SimpleTypebase
{
unknown
}
with {
variant "element";
};
......
......@@ -25,7 +25,7 @@
</xsd:documentation>
</xsd:annotation>
<xsd:element name="NameA" type="Name"/>
<xsd:element name="NameA" type="strng:Name"/>
<xsd:simpleType name="Name">
<xsd:restriction base="xsd:string">
......
......@@ -7,7 +7,7 @@
<xsd:attributeGroup ref="this:AttributeGroup"/>
</xsd:complexType>
<xsd:attribute name="remoteSchema" type="anyURI">
<xsd:attribute name="remoteSchema" type="xsd:anyURI">
</xsd:attribute>
<xsd:attributeGroup name="AttributeGroup">
......@@ -16,7 +16,7 @@
</xsd:attributeGroup>
<xsd:attributeGroup name="simpleLink">
<xsd:attribute name="type" type="string" fixed="simple" form="qualified"/>
<xsd:attribute name="type" type="xsd:string" fixed="simple" form="qualified"/>
</xsd:attributeGroup>
</xsd:schema>
......
......@@ -4,7 +4,7 @@ xmlns:ns45="attribute_in_extension"
targetNamespace="attribute_in_extension" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="BaseType">
<xs:sequence>
<xs:element name="Base-variable" type="integer" nillable="false">
<xs:element name="Base-variable" type="xs:integer" nillable="false">
</xs:element>
</xs:sequence>
</xs:complexType>
......@@ -14,7 +14,7 @@ targetNamespace="attribute_in_extension" elementFormDefault="qualified" attribut
<xs:complexType>
<xs:complexContent>
<xs:extension base="ns45:BaseType">
<xs:attribute name="extension" type="integer">
<xs:attribute name="extension" type="xs:integer">
</xs:attribute>
</xs:extension>
</xs:complexContent>
......
......@@ -3,17 +3,17 @@
targetNamespace="www.example.org/imported2">
<xsd:simpleType name="foobar">
<xsd:restriction base="integer"/>
<xsd:restriction base="xsd:integer"/>
</xsd:simpleType>
<xsd:simpleType name="ding">
<xsd:restriction base="integer"/>
<xsd:restriction base="xsd:integer"/>
</xsd:simpleType>
<xsd:element name="bar">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="something" type="string" minOccurs="0"/>
<xsd:element name="something" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
......
......@@ -3,17 +3,17 @@
targetNamespace="www.example.org/imported">
<xsd:simpleType name="foobar">
<xsd:restriction base="integer"/>
<xsd:restriction base="xsd:integer"/>
</xsd:simpleType>
<xsd:simpleType name="ding">
<xsd:restriction base="integer"/>
<xsd:restriction base="xsd:integer"/>
</xsd:simpleType>
<xsd:element name="bar">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="something" type="string" minOccurs="0"/>
<xsd:element name="something" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
......
......@@ -49,7 +49,9 @@
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="other:bar">
<xsd:element name="something" type="string" minOccurs="1"/>
<xsd:sequence>
<xsd:element name="something" type="string" minOccurs="1"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
......
......@@ -7,7 +7,7 @@
<xsd:complexType name="java-attribute" abstract="true">
<xsd:attribute name="java-attribute" type="xsd:string"/>
<xsd:attribute name="xml-accessor-type" type="string"/>
<xsd:attribute name="xml-accessor-type" type="xsd:string"/>
</xsd:complexType>
</xsd:schema>
......
......@@ -3,13 +3,20 @@
xmlns:this="www.example.org/simpletype/base"
targetNamespace="www.example.org/simpletype/base">
<xsd:complexType name="SimpleTypebase">
<xsd:simpleContent>
<xsd:restriction base="string">
<xsd:simpleType name="isknown">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="known"/>
<xsd:enumeration value="unknown"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="SimpleTypebase">
<xsd:simpleType>
<xsd:restriction base="this:isknown">
<xsd:enumeration value="unknown" />
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
</xsd:simpleType>
</xsd:element>
</xsd:schema>
......@@ -4,7 +4,7 @@
<xsd:import namespace="www.example.org/substitutiongroup/ref"/>
<xsd:element name="subsgroup" type="string" abstract="true" />
<xsd:element name="subsgroup" type="xsd:string" abstract="true" />
<xsd:element name="refgroup" type="A:subsgroup" />
......
......@@ -6,7 +6,7 @@
<xsd:import namespace="www.example.org/substitutiongroup/main"/>
<xsd:element name="replace" type="string" substitutionGroup="A:subsgroup"/>
<xsd:element name="replace" type="xsd:string" substitutionGroup="A:subsgroup"/>
</xsd:schema>
......@@ -18,9 +18,9 @@
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="Case" type="integer" abstract="true"/>
<xsd:element name="Case" type="xsd:integer" abstract="true"/>
<xsd:element name="BaseElement__" type="string" abstract="true"/>
<xsd:element name="BaseElement__" type="xsd:string" abstract="true"/>
<xsd:element name="BaseElement" type="this:BaseElement_" abstract="true"/>
......
......@@ -5,8 +5,8 @@
<xsd:element name="request" type="requestType" />
<xsd:element name="myProductionRequestType_" type="string" />
<xsd:element name="myProductionRequestType2_" type="string" />
<xsd:element name="myProductionRequestType_" type="xsd:string" />
<xsd:element name="myProductionRequestType2_" type="xsd:string" />
<!-- The generic base type -->
<xsd:complexType name="requestType">
......
......@@ -11,7 +11,7 @@
<xsd:extension base="A:ParentType">
<xsd:sequence>
</xsd:sequence>
<xsd:attribute name="attr1" type="string" />
<xsd:attribute name="attr1" type="xsd:string" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
......@@ -23,7 +23,7 @@
<xsd:element name="foo" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/>
<xsd:element name="bar" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="attr1" type="string" use="prohibited" />
<xsd:attribute name="attr1" type="xsd:string" use="prohibited" />
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
......
......@@ -3,13 +3,13 @@
targetNamespace="www.example.org/type/substitution/simple/cascade"
xmlns="www.example.org/type/substitution/simple/cascade">
<xsd:element name="elem" type="string"/>
<xsd:element name="elem" type="xsd:string"/>
<xsd:element name="elem1" type="stringtype"/>
<xsd:element name="elem2" type="stringtype2"/>
<xsd:element name="elem3" type="stringtype3"/>
<xsd:simpleType name="stringtype">
<xsd:restriction base="string"/>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:simpleType name="stringtype2">
......
......@@ -17,7 +17,7 @@
<xs:complexType name="MySeq">
<xs:sequence>
<xs:element name="i" type="integer" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="i" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
......
......@@ -17,7 +17,7 @@
<xs:complexType name="MySeqPrefix">
<xs:sequence>
<xs:element name="i" type="integer" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="i" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
......
......@@ -160,20 +160,20 @@ ComplexType::ComplexType(const SimpleType & other, CT_fromST c)
switch (c) {
case fromTagUnion:
type.upload(Mstring("union"));
type.upload(Mstring("union"), false);
with_union = true;
xsdtype = n_union;
break;
case fromTagNillable:
addVariant(V_useNil);
type.upload(Mstring("record"));
type.upload(Mstring("record"), false);
break;
case fromTagComplexType:
type.upload(Mstring("record"));
type.upload(Mstring("record"), false);
xsdtype = n_complexType;
break;
case fromTagSubstitution:
type.upload(Mstring("union"));
type.upload(Mstring("union"), false);
name.upload(getName().originalValueWoPrefix + Mstring("_group"));
xsdtype = n_union;
subsGroup = this;
......@@ -186,7 +186,7 @@ ComplexType::ComplexType(const SimpleType & other, CT_fromST c)
whitespace.modified = false;
break;
case fromTypeSubstitution:
type.upload(Mstring("union"));
type.upload(Mstring("union"), false);
name.upload(getName().originalValueWoPrefix + Mstring("_derivations"));
xsdtype = n_union;
substitutionGroup = empty_string;
......@@ -229,7 +229,7 @@ void ComplexType::loadWithValues() {
if (!top && xsdtype != n_sequence && xsdtype != n_complexType && xsdtype != n_extension && xsdtype != n_restriction && xsdtype != n_element) {
//Create new record
ComplexType * rec = new ComplexType(this);
rec->type.upload(Mstring("record"));
rec->type.upload(Mstring("record"), false);
rec->name.upload(Mstring("sequence"));
rec->addVariant(V_untagged);
rec->setMinMaxOccurs(atts.minOccurs, atts.maxOccurs);
......@@ -241,7 +241,7 @@ void ComplexType::loadWithValues() {
if (xsdtype == n_sequence && atts.minOccurs == 1 && atts.maxOccurs == 1) {
skipback += 1;
}
type.upload(Mstring("record"));
type.upload(Mstring("record"), false);
xsdtype = n_sequence;
setMinMaxOccurs(atts.minOccurs, atts.maxOccurs);
}
......@@ -250,7 +250,7 @@ void ComplexType::loadWithValues() {
if (!top || xsdtype != n_group) {
//Create new union field
ComplexType * choice = new ComplexType(this);
choice->type.upload(Mstring("union"));
choice->type.upload(Mstring("union"), false);
choice->name.upload(Mstring("choice"));
choice->setXsdtype(n_choice);
choice->addVariant(V_untagged);
......@@ -259,7 +259,7 @@ void ComplexType::loadWithValues() {
complexfields.push_back(choice);
} else {
xsdtype = n_choice;
type.upload(Mstring("union"));
type.upload(Mstring("union"), false);
}
break;
case n_all:
......@@ -332,7 +332,7 @@ void ComplexType::loadWithValues() {
//If a simple top level element is nillable
ComplexType * nilrec = new ComplexType(this);
if (atts.type.empty()) {
nilrec->type.upload(Mstring("record"));
nilrec->type.upload(Mstring("record"), false);
} else {
nilrec->type.upload(atts.type);
}
......@@ -341,7 +341,7 @@ void ComplexType::loadWithValues() {
nilrec->nillable = true;
setMinMaxOccurs(atts.minOccurs, atts.maxOccurs);
complexfields.push_back(nilrec);
type.upload(Mstring("record"));
type.upload(Mstring("record"), false);
name.upload(atts.name);
actfield = nilrec;
nillable_field = nilrec;
......@@ -350,12 +350,12 @@ void ComplexType::loadWithValues() {
ComplexType * record = new ComplexType(this);
ComplexType * nilrec = new ComplexType(record);
if (atts.type.empty()) {
nilrec->type.upload(Mstring("record"));
nilrec->type.upload(Mstring("record"), false);
} else {
nilrec->type.upload(atts.type);
}
record->name.upload(atts.name);
record->type.upload(Mstring("record"));
record->type.upload(Mstring("record"), false);
record->complexfields.push_back(nilrec);
record->addVariant(V_useNil);
record->nillable_field = nilrec;
......@@ -451,7 +451,7 @@ void ComplexType::loadWithValues() {
{
ComplexType * any = new ComplexType(this);
any->name.upload(Mstring("elem"));
any->type.upload(Mstring("xsd:string"));
any->type.upload(Mstring("string"), false);
any->applyNamespaceAttribute(V_anyElement, atts.namespace_);
any->setMinMaxOccurs(atts.minOccurs, atts.maxOccurs);
any->setXsdtype(n_any);
......@@ -463,7 +463,7 @@ void ComplexType::loadWithValues() {
AttributeType * anyattr = new AttributeType(this);
anyattr->setXsdtype(n_anyAttribute);
anyattr->setNameOfField(Mstring("attr"));
anyattr->setTypeValue(Mstring("xsd:string"));
anyattr->setTypeValue(Mstring("string"));
anyattr->setToAnyAttribute();
anyattr->applyMinMaxOccursAttribute(0, ULLONG_MAX);
anyattr->addNameSpaceAttribute(atts.namespace_);
......@@ -516,7 +516,7 @@ void ComplexType::loadWithValues() {
{
with_union = true;
xsdtype = n_union;
type.upload(Mstring("union"));
type.upload(Mstring("union"), false);
addVariant(V_useUnion);
if (!atts.memberTypes.empty()) {
List<Mstring> types;
......@@ -567,7 +567,7 @@ void ComplexType::loadWithValues() {
}
case n_complexType:
name.upload(atts.name);
type.upload(Mstring("record"));
type.upload(Mstring("record"), false);
applyAbstractAttribute(atts.abstract);
applySubstitionGroupAttribute(atts.substitionGroup);
applyBlockAttribute(atts.block);
......@@ -578,7 +578,7 @@ void ComplexType::loadWithValues() {
if (atts.mixed) {
ComplexType * mixed = new ComplexType(this);
mixed->name.upload(Mstring("embed_values"));
mixed->type.upload(Mstring("xsd:string"));
mixed->type.upload(Mstring("string"), false);
mixed->setMinMaxOccurs(0, ULLONG_MAX, false);
mixed->embed = true;
complexfields.push_back(mixed);
......@@ -1411,7 +1411,7 @@ void ComplexType::setMinMaxOccurs(const unsigned long long min, const unsigned l
first_child = false;
} else if (xsdtype == n_sequence) {
ComplexType * rec = new ComplexType(this);
rec->type.upload(Mstring("record"));
rec->type.upload(Mstring("record"), false);
rec->name.upload(Mstring("sequence"));
rec->setXsdtype(n_sequence);
rec->addVariant(V_untagged);
......
......@@ -519,7 +519,7 @@ bool matchDates(const char * string, const char * type) {
const Mstring second("([0-5][0-9])");
const Mstring endofdayext("24:00:00(.0?)?");
const Mstring yearext("((-)([1-9][0-9]*)?)?");
const Mstring timezone("(Z|[+-]((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?");
const Mstring time_zone("(Z|[+-]((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?");
const Mstring fraction("(.[0-9]+)?");
const Mstring nums("[0-9]+");
const Mstring durtime("(T[0-9]+"
......@@ -528,24 +528,24 @@ bool matchDates(const char * string, const char * type) {
Mstring pattern;
if (strcmp(type, "gDay") == 0) {
pattern = Mstring("(---)") + day + timezone;
pattern = Mstring("(---)") + day + time_zone;
} else if (strcmp(type, "gMonth") == 0) {
pattern = Mstring("(--)") + month + timezone;
pattern = Mstring("(--)") + month + time_zone;
} else if (strcmp(type, "gYear") == 0) {
pattern = yearext + year + timezone;
pattern = yearext + year + time_zone;
} else if (strcmp(type, "gYearMonth") == 0) {
pattern = yearext + year + Mstring("(-)") + month + timezone;
pattern = yearext + year + Mstring("(-)") + month + time_zone;
} else if (strcmp(type, "gMonthDay") == 0) {
pattern = Mstring("(--)") + month + Mstring("(-)") + day + timezone;
pattern = Mstring("(--)") + month + Mstring("(-)") + day + time_zone;
} else if (strcmp(type, "date") == 0) {
pattern = yearext + year + Mstring("(-)") + month + Mstring("(-)") + day + timezone;
pattern = yearext + year + Mstring("(-)") + month + Mstring("(-)") + day + time_zone;
} else if (strcmp(type, "time") == 0) {
pattern = Mstring("(") + hour + Mstring(":") + minute + Mstring(":") + second +
fraction + Mstring("|") + endofdayext + Mstring(")") + timezone;
fraction + Mstring("|") + endofdayext + Mstring(")") + time_zone;
} else if (strcmp(type, "dateTime") == 0) {
pattern = yearext + year + Mstring("(-)") + month + Mstring("(-)") + day +
Mstring("T(") + hour + Mstring(":") + minute + Mstring(":") + second +
fraction + Mstring("|") + endofdayext + Mstring(")") + timezone;
fraction + Mstring("|") + endofdayext + Mstring(")") + time_zone;
} else if (strcmp(type, "duration") == 0) {
pattern = Mstring("(-)?P(") + nums + Mstring("(Y(") + nums + Mstring("(M(") +
nums + Mstring("D") + durtime + Mstring("?|") + durtime + Mstring("?|D") +
......
......@@ -31,13 +31,13 @@ void ImportStatement::loadWithValues() {
switch (parser->getActualTagName()) {
case n_import:
name.upload(Mstring("import"));
type.upload(Mstring("import"));
type.upload(Mstring("import"), false);
from_namespace = attr.namespace_;
from_schemaLocation = attr.schemaLocation;
break;
case n_include:
name.upload(Mstring("include"));
type.upload(Mstring("include"));
type.upload(Mstring("include"), false);
from_namespace = attr.namespace_;
from_schemaLocation = attr.schemaLocation;
break;
......
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