--- /dev/null
+BUGS in MS Implementation of XmlSchema:\r
+\r
+1. Does not allow duplicate values in lists for final* and block* attributes. \r
+ For example "restriction restriction" is not allowed even though its a valid\r
+ value for blockDefault.\r
+\r
+2. Resets the minOccurs to 0 if maxOccurs="0", whereas it should raise an error.\r
+\r
+3. Allows abstract="true" in the a localElement whereas it is not allowed.\r
+ <?xml version="1.0"?>\r
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xsdtesting" xmlns:x="http://xsdtesting" elementFormDefault="qualified">\r
+ <xsd:element name="doc">\r
+ <xsd:complexType>\r
+ <xsd:sequence>\r
+ <xsd:element name="elem1"/>\r
+ <xsd:element abstract="true" name="elem2"/> <!--This element is not valid -->\r
+ </xsd:sequence>\r
+ </xsd:complexType>\r
+ </xsd:element>\r
+ </xsd:schema>
\ No newline at end of file
Bugs in Implementation:\r
\r
-1. Not all Compile methods check for the Id attribute. Trivial but needs to be done.\r
-2. None of the XmlSchemaObjects except the XmlSchema populate XmlSerializerNamespaces.\r
-3. Non schema attributes are not being handled. Need an internal XmlAttribute constructor.\r
+// None of the XmlSchemaObjects except the XmlSchema populate XmlSerializerNamespaces.\r
+2. Non schema attributes are not being handled. Need an internal XmlAttribute constructor.\r
+3. Documentation and appInfo's Markup is not being read in the Read() Method.\r
+2002-06-14 Dwivedi, Ajay kumar <adwiv@yahoo.com>
+ * General: Fixed a few more Bugs
+
2002-06-10 Dwivedi, Ajay kumar <adwiv@yahoo.com>
* XmlSchemaReader: A Wrapper class around XmlReader with customized
methods to suit reading a schema.
/// 2. finalDefault must be one of (#all | List of (extension | restriction| union| list))\r
/// 3. id must be of type ID\r
/// 4. targetNamespace should be any uri\r
- /// 5. version should be a token\r
+ /// 5. version should be a normalizedString\r
/// 6. xml:lang should be a language\r
- /// \r
/// </remarks>\r
[MonoTODO]\r
public void Compile(ValidationEventHandler handler)\r
{\r
+ // Create the xmlschemainfo object which we use to pass variables like targetnamespace;\r
+ info = new XmlSchemaInfo();\r
+\r
//1. Union and List are not allowed in block default\r
- if(this.blockDefault != XmlSchemaDerivationMethod.All)\r
+ if(BlockDefault != XmlSchemaDerivationMethod.All)\r
{\r
- if((this.blockDefault & XmlSchemaDerivationMethod.List)!=0 )\r
+ if((BlockDefault & XmlSchemaDerivationMethod.List)!=0 )\r
error(handler, "list is not allowed in blockDefault attribute");\r
- if((this.blockDefault & XmlSchemaDerivationMethod.Union)!=0 )\r
+ if((BlockDefault & XmlSchemaDerivationMethod.Union)!=0 )\r
error(handler, "union is not allowed in blockDefault attribute");\r
}\r
+\r
//2. Substitution is not allowed in finaldefault.\r
- if(this.finalDefault != XmlSchemaDerivationMethod.All)\r
+ if(FinalDefault != XmlSchemaDerivationMethod.All)\r
{\r
- if((this.finalDefault & XmlSchemaDerivationMethod.Substitution)!=0 )\r
+ if((FinalDefault & XmlSchemaDerivationMethod.Substitution)!=0 )\r
error(handler, "substitution is not allowed in finalDefault attribute");\r
}\r
+\r
//3. id must be of type ID\r
- if(this.id != null && !XmlSchemaUtil.CheckID(this.id))\r
- error(handler, "id attribute is not a valid ID");\r
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, handler);\r
\r
- //4. targetNamespace should be of type anyURI\r
- if(!XmlSchemaUtil.CheckAnyUri(this.targetNamespace))\r
- error(handler, "targetNamespace is not a valid URI");\r
+ //4. targetNamespace should be of type anyURI or absent\r
+ if(TargetNamespace != null)\r
+ {\r
+ if(!XmlSchemaUtil.CheckAnyUri(TargetNamespace))\r
+ error(handler, TargetNamespace+" is not a valid value for targetNamespace attribute of schema");\r
+ else\r
+ info.TargetNamespace = TargetNamespace;\r
+ }\r
\r
- //5. version should be of type TOKEN\r
- if(!XmlSchemaUtil.CheckToken(this.version))\r
- error(handler, "version is not a valid token");\r
+ //5. version should be of type normalizedString\r
+ if(!XmlSchemaUtil.CheckNormalizedString(Version))\r
+ error(handler, Version + "is not a valid value for version attribute of schema");\r
\r
//6. xml:lang must be a language\r
- if(!XmlSchemaUtil.CheckLanguage(this.language))\r
- error(handler, "xml:lang is not a valid language");\r
+ if(!XmlSchemaUtil.CheckLanguage(Language))\r
+ error(handler, Language + " is not a valid language");\r
\r
- // Create the xmlschemainfo object which we use to pass variables like targetnamespace;\r
- info = new XmlSchemaInfo();\r
- if(this.targetNamespace != null && XmlSchemaUtil.CheckAnyUri(this.targetNamespace))\r
- info.targetNS = this.TargetNamespace;\r
- \r
- if(this.ElementFormDefault != XmlSchemaForm.Qualified)\r
- info.formDefault = XmlSchemaForm.Unqualified;\r
+ // elementFormDefault defaults to UnQualified\r
+ if(ElementFormDefault != XmlSchemaForm.Qualified)\r
+ info.ElementFormDefault = XmlSchemaForm.Unqualified;\r
else\r
- info.formDefault = XmlSchemaForm.Qualified;\r
+ info.ElementFormDefault = XmlSchemaForm.Qualified;\r
+\r
+ // attributeFormDefault defaults to UnQualified\r
+ if(AttributeFormDefault != XmlSchemaForm.Qualified)\r
+ info.AttributeFormDefault = XmlSchemaForm.Unqualified;\r
+ else\r
+ info.AttributeFormDefault = XmlSchemaForm.Qualified;\r
\r
if(FinalDefault == XmlSchemaDerivationMethod.All)\r
- info.finalDefault = XmlSchemaDerivationMethod.All;\r
+ info.FinalDefault = XmlSchemaDerivationMethod.All;\r
else // If finalDefault is None, info's finalDefault is set to empty\r
- info.finalDefault = (FinalDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction));\r
+ info.FinalDefault = (FinalDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction));\r
\r
if(BlockDefault == XmlSchemaDerivationMethod.All)\r
- info.blockDefault = XmlSchemaDerivationMethod.All;\r
+ info.BlockDefault = XmlSchemaDerivationMethod.All;\r
else // If finalDefault is None, info's blockDefault is set to empty\r
- info.blockDefault = (blockDefault & (XmlSchemaDerivationMethod.Extension |\r
+ info.BlockDefault = (blockDefault & (XmlSchemaDerivationMethod.Extension |\r
XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution));\r
\r
// Compile the content of this schema\r
}\r
else\r
{\r
- error(handler,"Object of Type "+obj.GetType().Name+" is not valid in Includes Property of Schema");\r
+ error(handler,"Object of Type "+obj.GetType().Name+" is not valid in Includes Property of XmlSchema");\r
}\r
}\r
foreach(XmlSchemaObject obj in Items)\r
{\r
if(obj is XmlSchemaAnnotation)\r
{\r
- if(((XmlSchemaAnnotation)obj).Compile(handler,info) == 0)\r
+ int numerr = ((XmlSchemaAnnotation)obj).Compile(handler,info);\r
+ errorCount += numerr;\r
+ if( numerr == 0)\r
{\r
//FIXME: What PSVI set do we add this to?\r
}\r
{\r
XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;\r
attr.parentIsSchema = true;\r
- if(attr.Compile(handler,info) == 0)\r
+ int numerr = attr.Compile(handler,info);\r
+ errorCount += numerr; \r
+ if(numerr == 0)\r
{\r
Attributes.Add(attr.QualifiedName, attr);\r
}\r
else if(obj is XmlSchemaAttributeGroup)\r
{\r
XmlSchemaAttributeGroup attrgrp = (XmlSchemaAttributeGroup) obj;\r
- if(attrgrp.Compile(handler,info) == 0)\r
+ int numerr = attrgrp.Compile(handler,info);\r
+ errorCount += numerr; \r
+ if(numerr == 0)\r
{\r
AttributeGroups.Add(attrgrp.QualifiedName, attrgrp);\r
}\r
{\r
XmlSchemaComplexType ctype = (XmlSchemaComplexType) obj;\r
ctype.istoplevel = true;\r
- if(ctype.Compile(handler,info) == 0)\r
+ int numerr = ctype.Compile(handler,info);\r
+ errorCount += numerr; \r
+ if(numerr == 0)\r
{\r
schemaTypes.Add(ctype.QualifiedName, ctype);\r
}\r
{\r
XmlSchemaSimpleType stype = (XmlSchemaSimpleType) obj;\r
stype.islocal = false; //This simple type is toplevel\r
- if(stype.Compile(handler,info) == 0)\r
+ int numerr = stype.Compile(handler,info);\r
+ errorCount += numerr; \r
+ if(numerr == 0)\r
{\r
SchemaTypes.Add(stype.QualifiedName, stype);\r
}\r
{\r
XmlSchemaElement elem = (XmlSchemaElement) obj;\r
elem.parentIsSchema = true;\r
- if(elem.Compile(handler,info) == 0)\r
+ int numerr = elem.Compile(handler,info);\r
+ errorCount += numerr; \r
+ if(numerr == 0)\r
{\r
Elements.Add(elem.QualifiedName,elem);\r
}\r
else if(obj is XmlSchemaGroup)\r
{\r
XmlSchemaGroup grp = (XmlSchemaGroup) obj;\r
- if(grp.Compile(handler,info) == 0)\r
+ int numerr = grp.Compile(handler,info);\r
+ errorCount += numerr; \r
+ if(numerr == 0)\r
{\r
Groups.Add(grp.QualifiedName,grp);\r
}\r
else if(obj is XmlSchemaNotation)\r
{\r
XmlSchemaNotation ntn = (XmlSchemaNotation) obj;\r
- if(ntn.Compile(handler,info) == 0)\r
+ int numerr = ntn.Compile(handler,info);\r
+ errorCount += numerr; \r
+ if(numerr == 0)\r
{\r
Notations.Add(ntn.QualifiedName, ntn);\r
}\r
\r
foreach(XmlSchemaObject obj in Includes)\r
{\r
+ \r
}\r
\r
// foreach(XmlSchemaAnnotation ann in ??????)\r
return Read(new XmlTextReader(stream),validationEventHandler);\r
}\r
\r
- [MonoTODO]\r
public static XmlSchema Read(XmlReader rdr, ValidationEventHandler validationEventHandler)\r
{\r
//XmlSerializer xser = new XmlSerializer(typeof(XmlSchema));\r
writer.Flush();\r
}\r
}\r
-}\r
+}
\ No newline at end of file
[MonoTODO]\r
internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
{\r
+ //FIXME: Should we reset the values on error??\r
if(MaxOccurs != Decimal.One)\r
error(h,"maxOccurs must be 1");\r
if(MinOccurs != Decimal.One && MinOccurs != Decimal.Zero)\r
error(h,"minOccurs must be 0 or 1");\r
\r
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);\r
+\r
foreach(XmlSchemaObject obj in Items)\r
{\r
if(obj is XmlSchemaElement)\r
{\r
- errorCount += ((XmlSchemaElement)obj).Compile(h,info);\r
+ XmlSchemaElement elem = (XmlSchemaElement)obj;\r
+ if(elem.MaxOccurs != Decimal.One && elem.MaxOccurs != Decimal.Zero)\r
+ {\r
+ elem.error(h,"The {max occurs} of all the elements of 'all' must be 0 or 1. ");\r
+ }\r
+ errorCount += elem.Compile(h,info);\r
}\r
else\r
{\r
error(h,"XmlSchemaAll can only contain Items of type Element");\r
}\r
}\r
+\r
return errorCount;\r
}\r
- \r
+\r
[MonoTODO]\r
internal int Validate(ValidationEventHandler h)\r
{\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ all.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ all.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
[MonoTODO]\r
internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
{\r
- return 1;\r
+ return 0;\r
}\r
\r
[MonoTODO]\r
internal int Validate(ValidationEventHandler h)\r
{\r
- return 1;\r
+ return 0;\r
}\r
\r
//<annotation\r
}\r
else\r
{\r
- //TODO: Add to Unhandled attributes\r
+ if(reader.Prefix == "xmlns")\r
+ annotation.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ annotation.Namespaces.Add("",reader.Value);\r
+ //TODO: Add to Unhandled attributes\r
}\r
}\r
\r
{\r
errorCount = 0;\r
\r
- if(Id != null && !XmlSchemaUtil.CheckID(Id))\r
- {\r
- error(h, "id attribute must be a valid ID");\r
- }\r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
+\r
//define ##any=1,##other=2,##targetNamespace=4,##local=8,anyURI=16\r
int nscount = 0;\r
string[] nslist = XmlSchemaUtil.SplitList(Namespace);\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ any.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ any.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
{\r
errorCount = 0;\r
\r
- if(Id != null && !XmlSchemaUtil.CheckID(Id))\r
- {\r
- error(h, "id attribute must be a valid ID");\r
- }\r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
+\r
//define ##any=1,##other=2,##targetNamespace=4,##local=8,anyURI=16\r
int nscount = 0;\r
string[] nslist = XmlSchemaUtil.SplitList(Namespace);\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ any.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ any.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
/// 4. If default and use are both present, use must have the ·actual value· optional.\r
/// </remarks>\r
[MonoTODO]\r
- //FIXME: Should we set a property to null if an error occurs? Or should we stop the validation?\r
internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
{\r
errorCount = 0;\r
\r
if(parentIsSchema)//a\r
{\r
- if(this.refName!= null && !this.refName.IsEmpty) // a.1\r
+ if(RefName!= null && !RefName.IsEmpty) // a.1\r
error(h,"ref must be absent in the top level <attribute>");\r
\r
- if(this.form != XmlSchemaForm.None) // a.2\r
+ if(Form != XmlSchemaForm.None) // a.2\r
error(h,"form must be absent in the top level <attribute>");\r
\r
- if(this.use != XmlSchemaUse.None) // a.3\r
+ if(Use != XmlSchemaUse.None) // a.3\r
error(h,"use must be absent in the top level <attribute>");\r
\r
// TODO: a.10, a.11, a.12, a.13\r
}\r
else // local\r
{\r
- if(this.refName == null || this.refName.IsEmpty)\r
+ //FIXME: How to Use of AttributeFormDefault????\r
+ if(RefName == null || RefName.IsEmpty)\r
{\r
//TODO: b.8\r
CompileCommon(h,info, true);\r
{\r
if(refIsNotPresent)\r
{\r
- if(this.name == null) //a.4, b.1, \r
+ if(Name == null) //a.4, b.1, \r
error(h,"Required attribute name must be present");\r
- else if(!XmlSchemaUtil.CheckNCName(this.name)) // a.4.2, b1.2\r
+ else if(!XmlSchemaUtil.CheckNCName(Name)) // a.4.2, b1.2\r
error(h,"attribute name must be NCName");\r
- else if(this.name == "xmlns") // a.14 , b5\r
- error(h,"attribute name can't be xmlns");\r
+ else if(Name == "xmlns") // a.14 , b5\r
+ error(h,"attribute name must not be xmlns");\r
else\r
- this.qualifiedName = new XmlQualifiedName(this.name, info.targetNS); \r
+ qualifiedName = new XmlQualifiedName(Name, info.TargetNamespace); \r
\r
- if(this.schemaType != null)\r
+ if(SchemaType != null)\r
{\r
- if(this.schemaTypeName != null && !this.SchemaTypeName.IsEmpty) // a.8\r
+ if(SchemaTypeName != null && !SchemaTypeName.IsEmpty) // a.8\r
error(h,"attribute can't have both a type and <simpleType> content");\r
- else \r
- {\r
- errorCount += this.schemaType.Compile(h,info); \r
- }\r
+\r
+ errorCount += SchemaType.Compile(h,info); \r
}\r
+\r
+ if(SchemaTypeName != null && !XmlSchemaUtil.CheckQName(SchemaTypeName))\r
+ error(h,SchemaTypeName+" is not a valid QName");\r
}\r
else\r
{\r
- // redundant since we call function after check\r
- //if(this.refName == null || this.refName.IsEmpty) \r
- // error(h,"refname must be present");\r
- this.qualifiedName = this.refName;\r
+ if(RefName == null || RefName.IsEmpty) \r
+ error(h,"Error: Should Never Happen. refname must be present");\r
+ else\r
+ qualifiedName = RefName;\r
}\r
- if(info.targetNS == XmlSchema.InstanceNamespace && this.name != "nil" && this.name != "type" \r
- && this.name != "schemaLocation" && this.name != "noNamespaceSchemaLocation") // a.15, a.16\r
+\r
+ if(info.TargetNamespace == XmlSchema.InstanceNamespace && Name != "nil" && Name != "type" \r
+ && Name != "schemaLocation" && Name != "noNamespaceSchemaLocation") // a.15, a.16\r
error(h,"targetNamespace can't be " + XmlSchema.InstanceNamespace);\r
\r
- if(this.defaultValue != null && this.fixedValue != null) // a.6, b.3, c.3\r
+ if(DefaultValue != null && FixedValue != null) // a.6, b.3, c.3\r
error(h,"default and fixed must not both be present in an Attribute");\r
\r
- if(this.defaultValue != null && this.use != XmlSchemaUse.None && this.use != XmlSchemaUse.Optional)\r
+ if(DefaultValue != null && Use != XmlSchemaUse.None && Use != XmlSchemaUse.Optional)\r
error(h,"if default is present, use must be optional");\r
- \r
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
- error(h,"id attribute must be a valid ID");\r
+\r
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);\r
}\r
\r
[MonoTODO]\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ attribute.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ attribute.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
{\r
errorCount = 0;\r
\r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
+\r
if(this.Name == null) //1\r
error(h,"Name is required in top level simpletype");\r
else if(!XmlSchemaUtil.CheckNCName(this.Name)) // b.1.2\r
error(h,"name attribute of a simpleType must be NCName");\r
else\r
- this.qualifiedName = new XmlQualifiedName(this.Name,info.targetNS);\r
+ this.qualifiedName = new XmlQualifiedName(this.Name,info.TargetNamespace);\r
\r
if(this.AnyAttribute != null)\r
{\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ attrgrp.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ attrgrp.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
{\r
errorCount = 0;\r
- if(this.refName == null || this.refName.IsEmpty)\r
+ if(RefName == null || RefName.IsEmpty)\r
error(h, "ref must be present");\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
- error(h, "id must be a valid ID");\r
+ else if(!XmlSchemaUtil.CheckQName(RefName))\r
+ error(h, "ref must be a valid qname");\r
+\r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
+\r
// if(this.Annotation != null)\r
// error(h, "attributegroup with a ref can't have any content");\r
\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ attrgrp.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ attrgrp.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
[MonoTODO]\r
internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
{\r
+ //FIXME: Should we reset the values\r
+ if(MinOccurs > MaxOccurs)\r
+ error(h,"minOccurs must be less than or equal to maxOccurs");\r
+\r
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);\r
+\r
foreach(XmlSchemaObject obj in Items)\r
{\r
if(obj is XmlSchemaElement)\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ choice.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ choice.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
error(h,"complexContent can't have any value other than restriction or extention");\r
}\r
\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
- error(h, "id must be a valid ID");\r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
\r
return errorCount;\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ complex.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ complex.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
{\r
error(h, "base must be present and a QName");\r
}\r
+ else if(!XmlSchemaUtil.CheckQName(BaseTypeName))\r
+ error(h,"BaseTypeName is not a valid XmlQualifiedName");\r
\r
if(this.AnyAttribute != null)\r
{\r
errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);\r
}\r
}\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
- error(h, "id must be a valid ID");\r
\r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
+\r
return errorCount;\r
}\r
\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ extension.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ extension.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
{\r
error(h, "base must be present and a QName");\r
}\r
- \r
+ else if(!XmlSchemaUtil.CheckQName(BaseTypeName))\r
+ error(h,"BaseTypeName is not a valid XmlQualifiedName");\r
+\r
if(this.AnyAttribute != null)\r
{\r
errorCount += AnyAttribute.Compile(h,info);\r
errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);\r
}\r
}\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
- error(h, "id must be a valid ID");\r
\r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
+\r
return errorCount;\r
}\r
\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ restriction.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ restriction.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
{\r
if(this.Name == null || this.Name == string.Empty)\r
error(h,"name must be present in a top level complex type");\r
+ else if(!XmlSchemaUtil.CheckNCName(Name))\r
+ error(h,"name must be a NCName");\r
else\r
- {\r
- if(!XmlSchemaUtil.CheckNCName(Name))\r
- error(h,"name must be a NCName");\r
- else\r
- this.qName = new XmlQualifiedName(info.targetNS, Name);\r
- }\r
+ this.qName = new XmlQualifiedName(Name,info.TargetNamespace);\r
+ \r
if(Block != XmlSchemaDerivationMethod.None)\r
{\r
if(Block == XmlSchemaDerivationMethod.All)\r
}\r
else\r
{\r
- if(info.blockDefault == XmlSchemaDerivationMethod.All)\r
+ if(info.BlockDefault == XmlSchemaDerivationMethod.All)\r
{\r
blockResolved = XmlSchemaDerivationMethod.All;\r
}\r
else\r
- blockResolved = info.blockDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);\r
+ blockResolved = info.BlockDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);\r
}\r
if(Final != XmlSchemaDerivationMethod.None)\r
{\r
}\r
else\r
{\r
- if(info.finalDefault == XmlSchemaDerivationMethod.All)\r
+ if(info.FinalDefault == XmlSchemaDerivationMethod.All)\r
{\r
finalResolved = XmlSchemaDerivationMethod.All;\r
}\r
else\r
{\r
- finalResolved = info.blockDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);\r
+ finalResolved = info.BlockDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);\r
}\r
}\r
}\r
if(obj is XmlSchemaAttribute)\r
{\r
XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;\r
- attr.Compile(h,info);\r
+ errorCount += attr.Compile(h,info);\r
}\r
else if(obj is XmlSchemaAttributeGroupRef)\r
{\r
XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;\r
- atgrp.Compile(h,info);\r
+ errorCount += atgrp.Compile(h,info);\r
}\r
else\r
error(h,obj.GetType() +" is not valid in this place::ComplexType");\r
}\r
}\r
+\r
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);\r
return errorCount;\r
}\r
\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ ctype.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ ctype.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
\r
public XmlSchemaDocumentation()\r
{\r
- source = string.Empty;\r
}\r
\r
[XmlAnyElement]\r
{\r
if(this.refName != null && !RefName.IsEmpty)\r
error(h,"ref must be absent");\r
+\r
if(this.name == null) //b1\r
error(h,"Required attribute name must be present");\r
else if(!XmlSchemaUtil.CheckNCName(this.name)) // b1.2\r
error(h,"attribute name must be NCName");\r
else\r
- this.qName = new XmlQualifiedName(this.name, info.targetNS);\r
+ this.qName = new XmlQualifiedName(this.name, info.TargetNamespace);\r
\r
if(form != XmlSchemaForm.None)\r
error(h,"form must be absent");\r
if(MaxOccursString != null)\r
error(h,"maxOccurs must be absent");\r
\r
+ XmlSchemaDerivationMethod allfinal = (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);\r
if(final == XmlSchemaDerivationMethod.All)\r
- finalResolved = XmlSchemaDerivationMethod.All;\r
+ finalResolved = allfinal;\r
else if(final == XmlSchemaDerivationMethod.None)\r
- finalResolved = info.blockDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);\r
+ finalResolved = info.BlockDefault & allfinal;\r
else \r
- finalResolved = final & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);\r
+ {\r
+ if((final & ~allfinal) != 0)\r
+ warn(h,"some values for final are invalid in this context");\r
+ finalResolved = final & allfinal;\r
+ }\r
+\r
+ XmlSchemaDerivationMethod allblock = XmlSchemaDerivationMethod.Extension | \r
+ XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution;\r
\r
if(block == XmlSchemaDerivationMethod.All)\r
- blockResolved = XmlSchemaDerivationMethod.All;\r
+ blockResolved = allblock;\r
else if(block == XmlSchemaDerivationMethod.None)\r
- blockResolved = info.blockDefault & (XmlSchemaDerivationMethod.Extension | \r
- XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution);\r
- else \r
- blockResolved = block & (XmlSchemaDerivationMethod.Extension | \r
- XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution);\r
+ blockResolved = info.BlockDefault & allblock;\r
+ else\r
+ {\r
+ if((block & ~allblock) != 0)\r
+ warn(h,"Some of the values for block are invalid in this context");\r
+ blockResolved = block & allblock;\r
+ }\r
\r
if(schemaType != null && schemaTypeName != null && !schemaTypeName.IsEmpty)\r
{\r
error(h,"both schemaType and content can't be present");\r
}\r
- else\r
+\r
+ //Even if both are present, read both of them.\r
+ if(schemaType != null)\r
{\r
- if(schemaType != null)\r
+ if(schemaType is XmlSchemaSimpleType)\r
{\r
- if(schemaType is XmlSchemaSimpleType)\r
- {\r
- errorCount += ((XmlSchemaSimpleType)schemaType).Compile(h,info);\r
- }\r
- else if(schemaType is XmlSchemaComplexType)\r
- {\r
- errorCount += ((XmlSchemaComplexType)schemaType).Compile(h,info);\r
- }\r
- else\r
- error(h,"only simpletype or complextype is allowed");\r
+ errorCount += ((XmlSchemaSimpleType)schemaType).Compile(h,info);\r
}\r
- else\r
+ else if(schemaType is XmlSchemaComplexType)\r
{\r
- if(schemaTypeName == null || schemaTypeName.IsEmpty)\r
- error(h,"one of schemaType or schemaTypeName must be present: line 272");\r
+ errorCount += ((XmlSchemaComplexType)schemaType).Compile(h,info);\r
}\r
+ else\r
+ error(h,"only simpletype or complextype is allowed");\r
+ }\r
+ if(schemaTypeName != null && !schemaTypeName.IsEmpty)\r
+ {\r
+ if(!XmlSchemaUtil.CheckQName(SchemaTypeName))\r
+ error(h,"SchemaTypeName must be an XmlQualifiedName");\r
+ }\r
+ if(SubstitutionGroup != null && !SubstitutionGroup.IsEmpty)\r
+ {\r
+ if(!XmlSchemaUtil.CheckQName(SubstitutionGroup))\r
+ error(h,"SubstitutionGroup must be a valid XmlQualifiedName");\r
}\r
+\r
foreach(XmlSchemaObject obj in constraints)\r
{\r
if(obj is XmlSchemaUnique)\r
- ((XmlSchemaUnique)obj).Compile(h,info);\r
+ errorCount += ((XmlSchemaUnique)obj).Compile(h,info);\r
else if(obj is XmlSchemaKey)\r
- ((XmlSchemaKey)obj).Compile(h,info);\r
+ errorCount += ((XmlSchemaKey)obj).Compile(h,info);\r
else if(obj is XmlSchemaKeyref)\r
- ((XmlSchemaKeyref)obj).Compile(h,info);\r
+ errorCount += ((XmlSchemaKeyref)obj).Compile(h,info);\r
}\r
+\r
+\r
}\r
else\r
{\r
if(isAbstract)\r
error(h,"abstract must be absent");\r
\r
+ //FIXME: Should we reset the values\r
+ if(MinOccurs > MaxOccurs)\r
+ error(h,"minOccurs must be less than or equal to maxOccurs");\r
+\r
if(refName == null || RefName.IsEmpty)\r
{\r
- if(form == XmlSchemaForm.Qualified || (form == XmlSchemaForm.None && info.formDefault == XmlSchemaForm.Qualified))\r
- this.targetNamespace = info.targetNS;\r
+ if(form == XmlSchemaForm.Qualified || (form == XmlSchemaForm.None && info.ElementFormDefault == XmlSchemaForm.Qualified))\r
+ this.targetNamespace = info.TargetNamespace;\r
else\r
this.targetNamespace = string.Empty;\r
\r
else\r
this.qName = new XmlQualifiedName(this.name, this.targetNamespace);\r
\r
+ XmlSchemaDerivationMethod allblock = XmlSchemaDerivationMethod.Extension | \r
+ XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution;\r
+\r
if(block == XmlSchemaDerivationMethod.All)\r
- blockResolved = XmlSchemaDerivationMethod.All;\r
+ blockResolved = allblock;\r
else if(block == XmlSchemaDerivationMethod.None)\r
- blockResolved = info.blockDefault & (XmlSchemaDerivationMethod.Extension | \r
- XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution);\r
- else \r
- blockResolved = block & (XmlSchemaDerivationMethod.Extension | \r
- XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution);\r
+ blockResolved = info.BlockDefault & allblock;\r
+ else\r
+ {\r
+ if((block & ~allblock) != 0)\r
+ warn(h,"Some of the values for block are invalid in this context");\r
+ blockResolved = block & allblock;\r
+ }\r
\r
if(schemaType != null && schemaTypeName != null && !schemaTypeName.IsEmpty)\r
{\r
error(h,"both schemaType and content can't be present");\r
}\r
- else\r
+\r
+ //Even if both are present, read both of them.\r
+ if(schemaType != null)\r
{\r
- if(schemaType != null)\r
+ if(schemaType is XmlSchemaSimpleType)\r
{\r
- if(schemaType is XmlSchemaSimpleType)\r
- errorCount += ((XmlSchemaSimpleType)schemaType).Compile(h,info);\r
- else if(schemaType is XmlSchemaComplexType)\r
- errorCount += ((XmlSchemaComplexType)schemaType).Compile(h,info);\r
- else\r
- error(h,"only simpletype or complextype is allowed");\r
+ errorCount += ((XmlSchemaSimpleType)schemaType).Compile(h,info);\r
}\r
- else\r
+ else if(schemaType is XmlSchemaComplexType)\r
{\r
- if(schemaTypeName == null || schemaTypeName.IsEmpty)\r
- {\r
- error(h,"one of schemaType or schemaTypeName must be present: line 336 "+ hash);\r
- }\r
+ errorCount += ((XmlSchemaComplexType)schemaType).Compile(h,info);\r
}\r
+ else\r
+ error(h,"only simpletype or complextype is allowed");\r
+ }\r
+ if(schemaTypeName != null && !schemaTypeName.IsEmpty)\r
+ {\r
+ if(!XmlSchemaUtil.CheckQName(SchemaTypeName))\r
+ error(h,"SchemaTypeName must be an XmlQualifiedName");\r
+ }\r
+ if(SubstitutionGroup != null && !SubstitutionGroup.IsEmpty)\r
+ {\r
+ if(!XmlSchemaUtil.CheckQName(SubstitutionGroup))\r
+ error(h,"SubstitutionGroup must be a valid XmlQualifiedName");\r
}\r
\r
foreach(XmlSchemaObject obj in constraints)\r
{\r
if(obj is XmlSchemaUnique)\r
- ((XmlSchemaUnique)obj).Compile(h,info);\r
+ errorCount += ((XmlSchemaUnique)obj).Compile(h,info);\r
else if(obj is XmlSchemaKey)\r
- ((XmlSchemaKey)obj).Compile(h,info);\r
+ errorCount += ((XmlSchemaKey)obj).Compile(h,info);\r
else if(obj is XmlSchemaKeyref)\r
- ((XmlSchemaKeyref)obj).Compile(h,info);\r
+ errorCount += ((XmlSchemaKeyref)obj).Compile(h,info);\r
}\r
}\r
else\r
{\r
+ if(!XmlSchemaUtil.CheckQName(RefName))\r
+ error(h,"RefName must be a XmlQualifiedName");\r
+\r
if(name != null)\r
error(h,"name must not be present when ref is present");\r
if(Constraints.Count != 0)\r
error(h,"simpleType or complexType must be absent");\r
}\r
}\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
- error(h, "id must be a valid ID");\r
+ \r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
+\r
return errorCount;\r
}\r
\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ element.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ element.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ enumeration.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ enumeration.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ fraction.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ fraction.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
}\r
\r
// 1. name must be present\r
+ // 2. MinOccurs & MaxOccurs of the Particle must be absent\r
[MonoTODO]\r
internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
{\r
else if(!XmlSchemaUtil.CheckNCName(this.name)) \r
error(h,"attribute name must be NCName");\r
else\r
- qualifiedName = new XmlQualifiedName(Name,info.targetNS);\r
- \r
+ qualifiedName = new XmlQualifiedName(Name,info.TargetNamespace);\r
+\r
if(Particle == null)\r
{\r
error(h,"Particle is required");\r
}\r
- else if(Particle is XmlSchemaChoice)\r
- {\r
- errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);\r
- }\r
- else if(Particle is XmlSchemaSequence)\r
- {\r
- errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);\r
- }\r
- else if(Particle is XmlSchemaAll)\r
+ else \r
{\r
- errorCount += ((XmlSchemaAll)Particle).Compile(h,info);\r
- }\r
- else\r
- {\r
- error(h,"only all,choice or sequence are allowed");\r
+ if(Particle.MaxOccursString != null)\r
+ Particle.error(h,"MaxOccurs must not be present when the Particle is a child of Group");\r
+ if(Particle.MinOccursString != null)\r
+ Particle.error(h,"MinOccurs must not be present when the Particle is a child of Group");\r
+ \r
+ if(Particle is XmlSchemaChoice)\r
+ {\r
+ errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);\r
+ }\r
+ else if(Particle is XmlSchemaSequence)\r
+ {\r
+ errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);\r
+ }\r
+ else if(Particle is XmlSchemaAll)\r
+ {\r
+ errorCount += ((XmlSchemaAll)Particle).Compile(h,info);\r
+ }\r
+ else\r
+ {\r
+ error(h,"only all,choice or sequence are allowed");\r
+ }\r
}\r
-\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
- error(h, "id must be a valid ID");\r
+ \r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
\r
return errorCount;\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ group.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ group.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
[MonoTODO]\r
internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
{\r
+ //FIXME: Should we reset the values\r
+ if(MinOccurs > MaxOccurs)\r
+ error(h,"minOccurs must be less than or equal to maxOccurs");\r
+\r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
+\r
if(refName == null || refName.IsEmpty)\r
{\r
error(h,"ref must be present");\r
}\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
- error(h, "id must be a valid ID");\r
- \r
+ else if(!XmlSchemaUtil.CheckQName(RefName))\r
+ error(h, "RefName must be a valid XmlQualifiedName");\r
+\r
return errorCount;\r
}\r
\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ groupref.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ groupref.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
else if(!XmlSchemaUtil.CheckNCName(this.name)) \r
error(h,"attribute name must be NCName");\r
else\r
- this.qName = new XmlQualifiedName(Name,info.targetNS);\r
+ this.qName = new XmlQualifiedName(Name,info.TargetNamespace);\r
\r
//TODO: Compile Xpath. \r
if(Selector == null)\r
error(h,"selector must be present");\r
- \r
+ else\r
+ {\r
+ errorCount += Selector.Compile(h,info);\r
+ }\r
+\r
if(Fields.Count == 0)\r
error(h,"atleast one field value must be present");\r
-\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
- error(h, "id must be a valid ID");\r
+ else\r
+ {\r
+ foreach(XmlSchemaObject obj in Fields)\r
+ {\r
+ if(obj is XmlSchemaXPath)\r
+ {\r
+ XmlSchemaXPath field = (XmlSchemaXPath)obj;\r
+ errorCount += field.Compile(h,info);\r
+ }\r
+ else\r
+ error(h,"Object of type "+obj.GetType()+" is invalid in the Fields Collection");\r
+ }\r
+ }\r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
\r
return errorCount;\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ import.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ import.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ include.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ include.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
using System;\r
using System.Xml;\r
+using System.Collections;\r
\r
namespace System.Xml.Schema\r
{\r
/// <summary>\r
/// This class would store the infomation we need during compilation.\r
- /// (maybe during validation too.. who knows)\r
/// </summary>\r
internal class XmlSchemaInfo\r
{\r
internal XmlSchemaInfo()\r
- {}\r
+ {\r
+ IDCollection = new Hashtable();\r
+ }\r
\r
- internal string targetNS;\r
- internal XmlSchemaDerivationMethod finalDefault;\r
- internal XmlSchemaDerivationMethod blockDefault;\r
- internal XmlSchemaForm formDefault;\r
+ internal string TargetNamespace = null;\r
+ internal XmlSchemaDerivationMethod FinalDefault = XmlSchemaDerivationMethod.None;\r
+ internal XmlSchemaDerivationMethod BlockDefault = XmlSchemaDerivationMethod.None;\r
+ internal XmlSchemaForm ElementFormDefault = XmlSchemaForm.None;\r
+ internal XmlSchemaForm AttributeFormDefault = XmlSchemaForm.None;\r
+ internal Hashtable IDCollection;\r
}\r
-}\r
+}
\ No newline at end of file
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ key.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ key.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
if(level <= 3 && reader.LocalName == "field")\r
{\r
level = 3;\r
+ if(key.Selector == null)\r
+ error(h,"selector must be defined before field declarations",null);\r
XmlSchemaXPath field = XmlSchemaXPath.Read(reader,h,"field");\r
if(field != null)\r
key.Fields.Add(field);\r
[MonoTODO]\r
internal new int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
{\r
- errorCount = base.Compile(h,info);\r
+ errorCount += base.Compile(h,info);\r
if(refer == null || refer.IsEmpty)\r
error(h,"refer must be present");\r
+ else if(!XmlSchemaUtil.CheckQName(refer))\r
+ error(h,"Refer is not a valid XmlQualifiedName");\r
+\r
return errorCount;\r
}\r
\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ keyref.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ keyref.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
if(level <= 3 && reader.LocalName == "field")\r
{\r
level = 3;\r
+ if(keyref.Selector == null)\r
+ error(h,"selector must be defined before field declarations",null);\r
XmlSchemaXPath field = XmlSchemaXPath.Read(reader,h,"field");\r
if(field != null)\r
keyref.Fields.Add(field);\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ length.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ length.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ maxex.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ maxex.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ maxi.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ maxi.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ length.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ length.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ minex.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ minex.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ mini.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ mini.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ length.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ length.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
else if(!XmlSchemaUtil.CheckNCName(this.name)) \r
error(h,"attribute name must be NCName");\r
else\r
- qualifiedName = new XmlQualifiedName(Name,info.targetNS);\r
+ qualifiedName = new XmlQualifiedName(Name,info.TargetNamespace);\r
\r
- if(Public==null||Public == "")\r
+ if(Public==null)\r
error(h,"public must be present");\r
else if(!XmlSchemaUtil.CheckAnyUri(Public))\r
error(h,"public must be anyURI");\r
\r
- if(system != null && XmlSchemaUtil.CheckAnyUri(system))\r
- error(h,"system must be anyURI");\r
-\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
- error(h, "id must be a valid ID");\r
+ if(system != null && !XmlSchemaUtil.CheckAnyUri(system))\r
+ error(h,"system must be present and of Type anyURI");\r
+ \r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
\r
return errorCount;\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ notation.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ notation.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
{\r
ValidationHandler.RaiseValidationWarning(handle,message, innerException);\r
}\r
-\r
}\r
}
\ No newline at end of file
if(val >= 0 && (val == Decimal.Truncate(val)))\r
{\r
maxOccurs = val;\r
- maxstr = value;\r
+ maxstr = val.ToString();\r
}\r
else\r
{\r
if(val >= 0 && (val == Decimal.Truncate(val)))\r
{\r
minOccurs = val;\r
- minstr = value;\r
+ minstr = val.ToString();\r
}\r
else\r
{\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ pattern.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ pattern.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ redefine.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ redefine.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
[MonoTODO]\r
internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
{\r
+ //FIXME: Should we reset the values\r
+ if(MinOccurs > MaxOccurs)\r
+ error(h,"minOccurs must be less than or equal to maxOccurs");\r
+\r
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);\r
+\r
foreach(XmlSchemaObject obj in Items)\r
{\r
if(obj is XmlSchemaElement)\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ sequence.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ sequence.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
else\r
error(h,"simpleContent can't have any value other than restriction or extention");\r
}\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
- error(h, "id must be a valid ID");\r
+ \r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
return errorCount;\r
}\r
\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ simple.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ simple.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
{\r
error(h, "base must be present and a QName");\r
}\r
- \r
+ else if(!XmlSchemaUtil.CheckQName(BaseTypeName))\r
+ error(h,"BaseTypeName must be a QName");\r
+\r
if(this.AnyAttribute != null)\r
{\r
- AnyAttribute.Compile(h,info);\r
+ errorCount += AnyAttribute.Compile(h,info);\r
}\r
\r
foreach(XmlSchemaObject obj in Attributes)\r
if(obj is XmlSchemaAttribute)\r
{\r
XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;\r
- attr.Compile(h,info);\r
+ errorCount += attr.Compile(h,info);\r
}\r
- else if(obj is XmlSchemaAttributeGroup)\r
+ else if(obj is XmlSchemaAttributeGroupRef)\r
{\r
- XmlSchemaAttributeGroup atgrp = (XmlSchemaAttributeGroup) obj;\r
- atgrp.Compile(h,info);\r
+ XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;\r
+ errorCount += atgrp.Compile(h,info);\r
}\r
else\r
error(h,obj.GetType() +" is not valid in this place::SimpleConentExtension");\r
}\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
- error(h, "id must be a valid ID");\r
+ \r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
\r
return errorCount;\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ extension.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ extension.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
{\r
error(h, "base must be present and a QName");\r
}\r
+ else if(!XmlSchemaUtil.CheckQName(BaseTypeName))\r
+ error(h,"BaseTypeName must be a QName");\r
\r
if(BaseType != null)\r
{\r
\r
//TODO: Compile Facets: Looks like they are a part of datatypes. So we'll do them with the datatypes\r
\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
- error(h, "id must be a valid ID");\r
+ \r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
return errorCount;\r
}\r
\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ restriction.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ restriction.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
else if(!XmlSchemaUtil.CheckNCName(this.Name)) // b.1.2\r
error(h,"name attribute of a simpleType must be NCName");\r
else\r
- this.qName = new XmlQualifiedName(this.Name,info.targetNS);\r
+ this.qName = new XmlQualifiedName(this.Name,info.TargetNamespace);\r
\r
//NOTE: Although the FinalResolved can be Empty, it is not a valid value for Final\r
//DEVIATION: If an error occurs, the finaldefault is always consulted. This deviates\r
// from the way MS implementation works.\r
switch(this.Final) //b.3, b.4\r
{\r
- // Invalid values: Throw error and use "prohibited substitutions"\r
- case XmlSchemaDerivationMethod.Substitution:\r
- error(h,"substition is not a valid value for final in a simpletype");\r
- goto case XmlSchemaDerivationMethod.None;\r
- case XmlSchemaDerivationMethod.Extension:\r
- error(h,"extension is not a valid value for final in a simpletype");\r
- goto case XmlSchemaDerivationMethod.None;\r
- case XmlSchemaDerivationMethod.Empty:\r
- error(h,"empty is not a valid value for final in simpletype");\r
- goto case XmlSchemaDerivationMethod.None;\r
- //valid cases:\r
case XmlSchemaDerivationMethod.All:\r
this.finalResolved = XmlSchemaDerivationMethod.All;\r
break;\r
case XmlSchemaDerivationMethod.Restriction:\r
this.finalResolved = XmlSchemaDerivationMethod.Restriction;\r
break;\r
- // If mutliple values are specified\r
default:\r
- error(h,"simpletype can't have more than one value for final");\r
+ error(h,"The value of final attribute is not valid for simpleType");\r
goto case XmlSchemaDerivationMethod.None;\r
// use assignment from finaldefault on schema.\r
- // The possible values of finalDefault on schema are #all | List of (extension | restriction)\r
- // Of these, the only possible values for us are #all | restriction.\r
case XmlSchemaDerivationMethod.None: // b.5\r
- if(info.finalDefault == XmlSchemaDerivationMethod.All)\r
+ if(info.FinalDefault == XmlSchemaDerivationMethod.All)\r
finalResolved = XmlSchemaDerivationMethod.All;\r
- else // Either Restriction or Empty\r
- finalResolved = info.finalDefault & XmlSchemaDerivationMethod.Restriction;\r
+ else \r
+ finalResolved = info.FinalDefault & (XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.List |\r
+ XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Union );\r
break;\r
}\r
}\r
\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(this.Id))\r
- error(h,"id must be a valid ID");\r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
\r
if(this.Content == null) //a.3,b.2\r
error(h,"Content is required in a simpletype");\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ stype.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ stype.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
{\r
errorCount = 0;\r
\r
- if(this.itemType != null && !this.ItemTypeName.IsEmpty)\r
+ if(ItemType != null && !ItemTypeName.IsEmpty)\r
error(h, "both itemType and simpletype can't be present");\r
- if(this.itemType == null && this.ItemTypeName.IsEmpty)\r
+ if(ItemType == null && ItemTypeName.IsEmpty)\r
error(h, "one of itemType or simpletype must be present");\r
- if(this.itemType != null)\r
+ if(ItemType != null)\r
{\r
- errorCount += this.itemType.Compile(h,info);\r
+ errorCount += ItemType.Compile(h,info);\r
}\r
-\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(this.Id))\r
- error(h,"id must be a valid ID");\r
+ if(!XmlSchemaUtil.CheckQName(ItemTypeName))\r
+ error(h,"BaseTypeName must be a XmlQualifiedName");\r
+ \r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
\r
return errorCount;\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ list.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ list.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
{\r
errorCount += this.baseType.Compile(h,info);\r
}\r
+ if(!XmlSchemaUtil.CheckQName(BaseTypeName))\r
+ error(h,"BaseTypeName must be a XmlQualifiedName");\r
\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(this.Id))\r
- error(h,"id must be a valid ID");\r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
\r
return errorCount;\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ restriction.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ restriction.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
errorCount = 0;\r
\r
int count = BaseTypes.Count;\r
- if(MemberTypes != null)\r
- count += MemberTypes.Length;\r
-\r
- if(count == 0)\r
- error(h, "Atleast one simpletype or membertype must be present");\r
\r
foreach(XmlSchemaObject obj in baseTypes)\r
{\r
{\r
for(int i=0; i< memberTypes.Length; i++)\r
{\r
- if(memberTypes[i] == null)\r
+ if(memberTypes[i] == null || !XmlSchemaUtil.CheckQName(MemberTypes[i]))\r
{\r
- warn(h,"memberTypes should not have a null value");\r
+ warn(h,"Invalid membertype");\r
memberTypes[i] = XmlQualifiedName.Empty;\r
}\r
+ else\r
+ {\r
+ count += MemberTypes.Length;\r
+ }\r
}\r
}\r
\r
- if(this.Id != null && !XmlSchemaUtil.CheckID(this.Id))\r
- error(h,"id must be a valid ID");\r
+ if(count == 0)\r
+ error(h, "Atleast one simpletype or membertype must be present");\r
+\r
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);\r
\r
return errorCount;\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ union.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ union.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ td.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ td.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ unique.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ unique.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
if(level <= 3 && reader.LocalName == "field")\r
{\r
level = 3;\r
+ if(unique.Selector == null)\r
+ error(h,"selector must be defined before field declarations",null);\r
XmlSchemaXPath field = XmlSchemaXPath.Read(reader,h,"field");\r
if(field != null)\r
unique.Fields.Add(field);\r
using System;\r
using System.Xml;\r
+using System.Collections;\r
\r
namespace System.Xml.Schema\r
{\r
private XmlSchemaUtil()\r
{}\r
\r
- [MonoTODO]\r
- public static bool CheckID(string id)\r
+ public static void CompileID(string id, XmlSchemaObject xso, Hashtable idCollection, ValidationEventHandler h)\r
{\r
//check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#ID\r
// 1. ID must be a NCName\r
// 2. ID must be unique in the schema\r
+ if(id == null)\r
+ return;\r
if(!CheckNCName(id)) \r
- return false;\r
- //If !unique\r
-\r
- return true;\r
+ xso.error(h,id+" is not a valid id attribute");\r
+ else if(idCollection.ContainsKey(id))\r
+ xso.error(h,"Duplicate id attribute "+id);\r
+ else\r
+ idCollection.Add(id,xso);\r
}\r
\r
[MonoTODO]\r
//check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#token\r
return true;\r
}\r
+\r
+ public static bool CheckNormalizedString(string token)\r
+ {\r
+ return true;\r
+ }\r
+\r
public static bool CheckLanguage(string lang)\r
{\r
//check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#language\r
}\r
}\r
\r
+ public static bool CheckQName(XmlQualifiedName qname)\r
+ {\r
+ return true;\r
+ }\r
public static bool IsValidQName(string qname)\r
{\r
foreach(string part in qname.Split(new char[]{':'},2))\r
return decimal.Zero;\r
}\r
}\r
+\r
+ // Is some value is read, return it.\r
+ // If no values return empty.\r
+ // If exception, return none\r
public static XmlSchemaDerivationMethod ReadDerivationAttribute(XmlReader reader, out Exception innerExcpetion, string name)\r
{\r
innerExcpetion = null;\r
{\r
string list = reader.Value;\r
string warn = "";\r
- XmlSchemaDerivationMethod val = XmlSchemaDerivationMethod.None;\r
+ XmlSchemaDerivationMethod val = 0;\r
\r
if(list.IndexOf("#all") != -1 && list.Trim() != "#all")\r
{\r
catch(Exception ex)\r
{\r
innerExcpetion = ex;\r
- return 0;\r
+ return XmlSchemaDerivationMethod.None;\r
}\r
}\r
\r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ ws.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ ws.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r
get{ return xpath; } \r
set{ xpath = value; }\r
}\r
+\r
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
+ {\r
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);\r
+ return errorCount;\r
+ }\r
+\r
//<selector \r
// id = ID \r
// xpath = a subset of XPath expression, see below \r
}\r
else\r
{\r
+ if(reader.Prefix == "xmlns")\r
+ path.Namespaces.Add(reader.LocalName, reader.Value);\r
+ else if(reader.Name == "xmlns")\r
+ path.Namespaces.Add("",reader.Value);\r
//TODO: Add to Unhandled attributes\r
}\r
}\r