Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/System.XML/System.Xml.Schema')
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/BUGS-MS.txt20
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/BUGS.txt5
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/ChangeLog69
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/ValidationEventArgs.cs38
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/ValidationHandler.cs48
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchema.cs711
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAll.cs165
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotated.cs56
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotation.cs145
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAny.cs192
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAnyAttribute.cs169
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAppInfo.cs91
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs435
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroup.cs208
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroupRef.cs126
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaChoice.cs203
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaCollection.cs130
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaCollectionEnumerator.cs47
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContent.cs162
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentExtension.cs254
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs256
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs463
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaContent.cs15
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaContentModel.cs19
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaContentProcessing.cs22
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaContentType.cs17
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs30
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaDerivationMethod.cs31
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaDocumentation.cs104
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs625
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaEnumerationFacet.cs87
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaException.cs94
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaExternal.cs62
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaFacet.cs37
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaForm.cs19
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaFractionDigitsFacet.cs98
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaGroup.cs195
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupBase.cs20
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs156
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaIdentityConstraint.cs91
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaImport.cs109
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaInclude.cs97
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaInfo.cs25
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaKey.cs127
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaKeyref.cs151
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaLengthFacet.cs96
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.cs96
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.cs96
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxLengthFacet.cs97
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaMinExclusiveFacet.cs96
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaMinInclusiveFacet.cs95
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaMinLengthFacet.cs96
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaNotation.cs158
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaNumericFacet.cs16
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaObject.cs75
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectCollection.cs88
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectEnumerator.cs49
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectTable.cs51
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaParticle.cs98
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaPatternFacet.cs87
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaReader.cs358
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaRedefine.cs151
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSequence.cs202
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContent.cs146
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentExtension.cs190
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs337
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleType.cs237
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeContent.cs17
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeList.cs152
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs267
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeUnion.cs175
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaTotalDigitsFacet.cs96
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs81
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs126
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaUse.cs22
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaUtil.cs299
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.cs97
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaXPath.cs104
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSeverityType.cs15
79 files changed, 10590 insertions, 0 deletions
diff --git a/mcs/class/System.XML/System.Xml.Schema/BUGS-MS.txt b/mcs/class/System.XML/System.Xml.Schema/BUGS-MS.txt
new file mode 100755
index 00000000000..ad4ece9c910
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/BUGS-MS.txt
@@ -0,0 +1,20 @@
+BUGS in MS Implementation of XmlSchema:
+
+1. Does not allow duplicate values in lists for final* and block* attributes.
+ For example "restriction restriction" is not allowed even though its a valid
+ value for blockDefault.
+
+2. Resets the minOccurs to 0 if maxOccurs="0", whereas it should raise an error.
+
+3. Allows abstract="true" in the a localElement whereas it is not allowed.
+ <?xml version="1.0"?>
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xsdtesting" xmlns:x="http://xsdtesting" elementFormDefault="qualified">
+ <xsd:element name="doc">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="elem1"/>
+ <xsd:element abstract="true" name="elem2"/> <!--This element is not valid -->
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema> \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/BUGS.txt b/mcs/class/System.XML/System.Xml.Schema/BUGS.txt
new file mode 100755
index 00000000000..cf602178c3d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/BUGS.txt
@@ -0,0 +1,5 @@
+Bugs in Implementation:
+
+// None of the XmlSchemaObjects except the XmlSchema populate XmlSerializerNamespaces.
+//2. Non schema attributes are not being handled. Need an internal XmlAttribute constructor.
+//3. Documentation and appInfo's Markup is not being read in the Read() Method.
diff --git a/mcs/class/System.XML/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
new file mode 100755
index 00000000000..13917ba73c5
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
@@ -0,0 +1,69 @@
+2002-07-23 Duncan Mak <duncan@ximian.com>
+
+ * XmlSchemaException.cs: Partiall implement the ISerializable
+ methods. It's not clear now SourceSchemaObject should be deserialized.
+
+2002-07-22 Tim Coleman <tim@timcoleman.com>
+ * XmlSchema.cs: Removed isCompiled which is defined as internal
+ in XmlSchemaObject.
+
+2002-06-18 Dwivedi, Ajay kumar <adwiv@yahoo.com>
+
+ * XmlSchema: Started work on Validate methods
+
+2002-06-18 Dwivedi, Ajay kumar <adwiv@yahoo.com>
+ * XmlSchema: The Read and Write methods are no more [MonoTODO] :)
+
+ * XmlSchemaAppInfo: Xml Markup is now being read.
+
+ * XmlSchemaDocumentation: Xml Markup is now being read.
+
+ * All: Unhandled attributes are being handled properly.
+
+ * All: Reordered the properties in all cs files to match with MS
+ Implementation. This was required since the order is importatnt
+ for the XmlSerializer.
+
+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.
+ * General: Implemented Read() method for the schema. There are only
+ a few minor bugs remaining.
+
+2002-05-25 Dwivedi, Ajay kumar <adwiv@yahoo.com>
+ * BUGS.txt: New file to keep track of bugs
+
+ * ALL: All classes are initialized exactly as in .NET except
+ 1. inclusion of language attribute in schema
+ 2. ComplexContent's Particle is initialized to null whereas .NET
+ to some internal implementation. IMO Null is more appropriate
+
+ * ALL: Changed the Compile methods to return the count of errors.
+
+ * ALL: Complile methods are almost complete. Pass 1453 of 3061 tests.
+ This number should shoot up if we write a parser to read the
+ Schema instead of using reflection (which is slower too)
+
+2002-05-04 Dwivedi, Ajay kumar <adwiv@yahoo.com>
+ * XmlSchemaUtil.cs: New file added.
+
+ * Parser.cs: New file Added. Unused at the moment.
+
+ * XmlSchemaObjectCollection: Fixed GetEnumerator
+
+ * General: Preprocessing for Attributes and SimpleTypes completed.
+
+2002-04-26 Duncan Mak <duncan@ximian.com>
+
+ * ValidationHandler.cs: New file.
+
+ * XmlSchemaInfo.cs: New file.
+
+ * *.cs: More updates from Ajay.
+
+2002-03-27 Duncan Mak <duncan@ximian.com>
+
+ * *.cs: Updates from Ajay Dwivedi <AjayKumar.Dwivedi@dresdner-bank.com>.
diff --git a/mcs/class/System.XML/System.Xml.Schema/ValidationEventArgs.cs b/mcs/class/System.XML/System.Xml.Schema/ValidationEventArgs.cs
new file mode 100755
index 00000000000..df846514e1e
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/ValidationEventArgs.cs
@@ -0,0 +1,38 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for ValidationEventArgs.
+ /// </summary>
+ public sealed class ValidationEventArgs : EventArgs
+ {
+ private XmlSchemaException exception;
+ private string message;
+ private XmlSeverityType severity;
+
+ private ValidationEventArgs()
+ {}
+
+ internal ValidationEventArgs(XmlSchemaException ex, string message, XmlSeverityType severity)
+ {
+ this.exception = ex;
+ this.message = message;
+ this.severity = severity;
+ }
+ public XmlSchemaException Exception
+ {
+ get{ return exception; }
+ }
+ public string Message
+ {
+ get{ return message; }
+ }
+ public XmlSeverityType Severity
+ {
+ get{ return severity; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/ValidationHandler.cs b/mcs/class/System.XML/System.Xml.Schema/ValidationHandler.cs
new file mode 100755
index 00000000000..898a10a840f
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/ValidationHandler.cs
@@ -0,0 +1,48 @@
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// </summary>
+ public delegate void ValidationEventHandler(object sender,ValidationEventArgs e);
+
+ /// <summary>
+ /// Docs say we need to raise an exception if ValidationEventHandler is not set(null)
+ /// So we use this class to raise the events rather than calling the delegate by itself
+ /// </summary>
+ internal class ValidationHandler
+ {
+ public static void RaiseValidationEvent(ValidationEventHandler handle, Exception innerException, object sender, string message, XmlSeverityType severity)
+ {
+ XmlSchemaException ex = new XmlSchemaException(message,innerException);
+ ValidationEventArgs e = new ValidationEventArgs(ex,message,severity);
+ if(handle == null)
+ {
+ throw e.Exception;
+ }
+ else
+ {
+ handle(sender,e);
+ }
+ }
+ public static void RaiseValidationError(ValidationEventHandler handle, object sender, string message)
+ {
+ RaiseValidationEvent(handle,null,sender,message,XmlSeverityType.Error);
+ }
+
+ public static void RaiseValidationError(ValidationEventHandler handle, string message, Exception innerException)
+ {
+ RaiseValidationEvent(handle, innerException, null, message, XmlSeverityType.Error);
+ }
+
+ public static void RaiseValidationWarning (ValidationEventHandler handle, object sender, string message)
+ {
+ RaiseValidationEvent(handle,null,sender,message,XmlSeverityType.Warning);
+ }
+
+ public static void RaiseValidationWarning(ValidationEventHandler handle, string message, Exception innerException)
+ {
+ RaiseValidationEvent(handle, innerException, null, message, XmlSeverityType.Warning);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs
new file mode 100755
index 00000000000..61f16ec71ca
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs
@@ -0,0 +1,711 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+using System.Xml;
+using System.IO;
+using System.Xml.Serialization;
+using System.ComponentModel;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchema.
+ /// </summary>
+ [XmlRoot("schema",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public class XmlSchema : XmlSchemaObject
+ {
+ //public constants
+ public const string Namespace = "http://www.w3.org/2001/XMLSchema";
+ public const string InstanceNamespace = "http://www.w3.org/2001/XMLSchema-instance";
+
+ //private fields
+ private XmlSchemaForm attributeFormDefault ;
+ private XmlSchemaObjectTable attributeGroups ;
+ private XmlSchemaObjectTable attributes ;
+ private XmlSchemaDerivationMethod blockDefault ;
+ private XmlSchemaForm elementFormDefault ;
+ private XmlSchemaObjectTable elements ;
+ private XmlSchemaDerivationMethod finalDefault ;
+ private XmlSchemaObjectTable groups ;
+ private string id ;
+ private XmlSchemaObjectCollection includes ;
+ private XmlSchemaObjectCollection items ;
+ private XmlSchemaObjectTable notations ;
+ private XmlSchemaObjectTable schemaTypes ;
+ private string targetNamespace ;
+ private XmlAttribute[] unhandledAttributes ;
+ private string version;
+ private string language;
+
+ // Compiler specific things
+ private XmlSchemaInfo info;
+ private static string xmlname = "schema";
+
+ public XmlSchema()
+ {
+ attributeFormDefault= XmlSchemaForm.None;
+ blockDefault = XmlSchemaDerivationMethod.None;
+ elementFormDefault = XmlSchemaForm.None;
+ finalDefault = XmlSchemaDerivationMethod.None;
+ includes = new XmlSchemaObjectCollection();
+ isCompiled = false;
+ items = new XmlSchemaObjectCollection();
+ attributeGroups = new XmlSchemaObjectTable();
+ attributes = new XmlSchemaObjectTable();
+ elements = new XmlSchemaObjectTable();
+ groups = new XmlSchemaObjectTable();
+ notations = new XmlSchemaObjectTable();
+ schemaTypes = new XmlSchemaObjectTable();
+ }
+
+ #region Properties
+
+ [DefaultValue(XmlSchemaForm.None)]
+ [System.Xml.Serialization.XmlAttribute("attributeFormDefault")]
+ public XmlSchemaForm AttributeFormDefault
+ {
+ get{ return attributeFormDefault; }
+ set{ this.attributeFormDefault = value;}
+ }
+
+ [DefaultValue(XmlSchemaDerivationMethod.None)]
+ [System.Xml.Serialization.XmlAttribute("blockDefault")]
+ public XmlSchemaDerivationMethod BlockDefault
+ {
+ get{ return blockDefault;}
+ set{ blockDefault = value;}
+ }
+
+ [DefaultValue(XmlSchemaDerivationMethod.None)]
+ [System.Xml.Serialization.XmlAttribute("finalDefault")]
+ public XmlSchemaDerivationMethod FinalDefault
+ {
+ get{ return finalDefault;}
+ set{ finalDefault = value;}
+ }
+
+ [DefaultValue(XmlSchemaForm.None)]
+ [System.Xml.Serialization.XmlAttribute("elementFormDefault")]
+ public XmlSchemaForm ElementFormDefault
+ {
+ get{ return elementFormDefault;}
+ set{ elementFormDefault = value;}
+ }
+
+ [System.Xml.Serialization.XmlAttribute("targetNamespace")]
+ public string TargetNamespace
+ {
+ get{ return targetNamespace;}
+ set{ targetNamespace = value;}
+ }
+
+ [System.Xml.Serialization.XmlAttribute("version")]
+ public string Version
+ {
+ get{ return version;}
+ set{ version = value;}
+ }
+
+ [XmlElement("include",typeof(XmlSchemaInclude),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("import",typeof(XmlSchemaImport),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("redefine",typeof(XmlSchemaRedefine),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Includes
+ {
+ get{ return includes;}
+ }
+
+ [XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("complexType",typeof(XmlSchemaComplexType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("group",typeof(XmlSchemaGroup),Namespace="http://www.w3.org/2001/XMLSchema")]
+ //Only Schema's attributeGroup has type XmlSchemaAttributeGroup.
+ //Others (complextype, restrictions etc) must have XmlSchemaAttributeGroupRef
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroup),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("element",typeof(XmlSchemaElement),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("notation",typeof(XmlSchemaNotation),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("annotation",typeof(XmlSchemaAnnotation),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Items
+ {
+ get{ return items;}
+ }
+
+ [XmlIgnore]
+ public bool IsCompiled
+ {
+ get{ return isCompiled;}
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable Attributes
+ {
+ get{ return attributes;}
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable AttributeGroups
+ {
+ get{ return attributeGroups; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable SchemaTypes
+ {
+ get{ return schemaTypes; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable Elements
+ {
+ get{ return elements;}
+ }
+
+ [System.Xml.Serialization.XmlAttribute("id")]
+ public string Id
+ {
+ get{ return id;}
+ set{ id = value;}
+ }
+
+ [XmlAnyAttribute]
+ public XmlAttribute[] UnhandledAttributes
+ {
+ get
+ {
+ if(unhandledAttributeList != null)
+ {
+ unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
+ unhandledAttributeList = null;
+ }
+ return unhandledAttributes;
+ }
+ set
+ {
+ unhandledAttributes = value;
+ unhandledAttributeList = null;
+ }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable Groups
+ {
+ get{ return groups;}
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable Notations
+ {
+ get{ return notations;}
+ }
+
+ // New attribute defined in W3C schema element
+ [System.Xml.Serialization.XmlAttribute("xml:lang")]
+ public string Language
+ {
+ get{ return language; }
+ set{ language = value; }
+ }
+
+ #endregion
+
+ #region Compile
+
+ // Methods
+ /// <summary>
+ /// This compile method does two things:
+ /// 1. It compiles and fills the PSVI dataset
+ /// 2. Validates the schema by calling Validate method.
+ /// Every XmlSchemaObject has a Compile Method which gets called.
+ /// </summary>
+ /// <remarks>
+ /// 1. blockDefault must be one of #all | List of (extension | restriction | substitution)
+ /// 2. finalDefault must be one of (#all | List of (extension | restriction| union| list))
+ /// 3. id must be of type ID
+ /// 4. targetNamespace should be any uri
+ /// 5. version should be a normalizedString
+ /// 6. xml:lang should be a language
+ /// </remarks>
+ [MonoTODO]
+ public void Compile(ValidationEventHandler handler)
+ {
+ // Create the xmlschemainfo object which we use to pass variables like targetnamespace;
+ info = new XmlSchemaInfo();
+
+ //1. Union and List are not allowed in block default
+ if(BlockDefault != XmlSchemaDerivationMethod.All)
+ {
+ if((BlockDefault & XmlSchemaDerivationMethod.List)!=0 )
+ error(handler, "list is not allowed in blockDefault attribute");
+ if((BlockDefault & XmlSchemaDerivationMethod.Union)!=0 )
+ error(handler, "union is not allowed in blockDefault attribute");
+ }
+
+ //2. Substitution is not allowed in finaldefault.
+ if(FinalDefault != XmlSchemaDerivationMethod.All)
+ {
+ if((FinalDefault & XmlSchemaDerivationMethod.Substitution)!=0 )
+ error(handler, "substitution is not allowed in finalDefault attribute");
+ }
+
+ //3. id must be of type ID
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, handler);
+
+ //4. targetNamespace should be of type anyURI or absent
+ if(TargetNamespace != null)
+ {
+ if(!XmlSchemaUtil.CheckAnyUri(TargetNamespace))
+ error(handler, TargetNamespace+" is not a valid value for targetNamespace attribute of schema");
+ else
+ info.TargetNamespace = TargetNamespace;
+ }
+
+ //5. version should be of type normalizedString
+ if(!XmlSchemaUtil.CheckNormalizedString(Version))
+ error(handler, Version + "is not a valid value for version attribute of schema");
+
+ //6. xml:lang must be a language
+ if(!XmlSchemaUtil.CheckLanguage(Language))
+ error(handler, Language + " is not a valid language");
+
+ // elementFormDefault defaults to UnQualified
+ if(ElementFormDefault != XmlSchemaForm.Qualified)
+ info.ElementFormDefault = XmlSchemaForm.Unqualified;
+ else
+ info.ElementFormDefault = XmlSchemaForm.Qualified;
+
+ // attributeFormDefault defaults to UnQualified
+ if(AttributeFormDefault != XmlSchemaForm.Qualified)
+ info.AttributeFormDefault = XmlSchemaForm.Unqualified;
+ else
+ info.AttributeFormDefault = XmlSchemaForm.Qualified;
+
+ if(FinalDefault == XmlSchemaDerivationMethod.All)
+ info.FinalDefault = XmlSchemaDerivationMethod.All;
+ else // If finalDefault is None, info's finalDefault is set to empty
+ info.FinalDefault = (FinalDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction));
+
+ if(BlockDefault == XmlSchemaDerivationMethod.All)
+ info.BlockDefault = XmlSchemaDerivationMethod.All;
+ else // If finalDefault is None, info's blockDefault is set to empty
+ info.BlockDefault = (blockDefault & (XmlSchemaDerivationMethod.Extension |
+ XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution));
+
+ // Compile the content of this schema
+ foreach(XmlSchemaObject obj in Includes)
+ {
+ if(obj is XmlSchemaExternal)
+ {
+ //FIXME: Kuch to karo! (Do Something ;)
+ }
+ else
+ {
+ error(handler,"Object of Type "+obj.GetType().Name+" is not valid in Includes Property of XmlSchema");
+ }
+ }
+ foreach(XmlSchemaObject obj in Items)
+ {
+ if(obj is XmlSchemaAnnotation)
+ {
+ int numerr = ((XmlSchemaAnnotation)obj).Compile(handler,info);
+ errorCount += numerr;
+ if( numerr == 0)
+ {
+ //FIXME: What PSVI set do we add this to?
+ }
+ }
+ else if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ attr.parentIsSchema = true;
+ int numerr = attr.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ Attributes.Add(attr.QualifiedName, attr);
+ }
+ }
+ else if(obj is XmlSchemaAttributeGroup)
+ {
+ XmlSchemaAttributeGroup attrgrp = (XmlSchemaAttributeGroup) obj;
+ int numerr = attrgrp.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ AttributeGroups.Add(attrgrp.QualifiedName, attrgrp);
+ }
+ }
+ else if(obj is XmlSchemaComplexType)
+ {
+ XmlSchemaComplexType ctype = (XmlSchemaComplexType) obj;
+ ctype.istoplevel = true;
+ int numerr = ctype.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ schemaTypes.Add(ctype.QualifiedName, ctype);
+ }
+ }
+ else if(obj is XmlSchemaSimpleType)
+ {
+ XmlSchemaSimpleType stype = (XmlSchemaSimpleType) obj;
+ stype.islocal = false; //This simple type is toplevel
+ int numerr = stype.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ SchemaTypes.Add(stype.QualifiedName, stype);
+ }
+ }
+ else if(obj is XmlSchemaElement)
+ {
+ XmlSchemaElement elem = (XmlSchemaElement) obj;
+ elem.parentIsSchema = true;
+ int numerr = elem.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ Elements.Add(elem.QualifiedName,elem);
+ }
+ }
+ else if(obj is XmlSchemaGroup)
+ {
+ XmlSchemaGroup grp = (XmlSchemaGroup) obj;
+ int numerr = grp.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ Groups.Add(grp.QualifiedName,grp);
+ }
+ }
+ else if(obj is XmlSchemaNotation)
+ {
+ XmlSchemaNotation ntn = (XmlSchemaNotation) obj;
+ int numerr = ntn.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ Notations.Add(ntn.QualifiedName, ntn);
+ }
+ }
+ else
+ {
+ ValidationHandler.RaiseValidationError(handler,this,
+ "Object of Type "+obj.GetType().Name+" is not valid in Item Property of Schema");
+ }
+ }
+ Validate(handler);
+ }
+
+ #endregion
+
+ [MonoTODO]
+ private void Validate(ValidationEventHandler handler)
+ {
+ info.SchemaTypes = SchemaTypes;
+
+ foreach(XmlSchemaAttribute attr in Attributes.Values)
+ {
+ attr.Validate(handler, info);
+ }
+ foreach(XmlSchemaAttributeGroup attrgrp in AttributeGroups.Values)
+ {
+ attrgrp.Validate(handler);
+ }
+ foreach(XmlSchemaType type in SchemaTypes.Values)
+ {
+ if(type is XmlSchemaComplexType)
+ {
+ ((XmlSchemaComplexType)type).Validate(handler);
+ }
+ else
+ ((XmlSchemaSimpleType)type).Validate(handler, info);
+ }
+ foreach(XmlSchemaElement elem in Elements.Values)
+ {
+ elem.Validate(handler);
+ }
+ foreach(XmlSchemaGroup grp in Groups.Values)
+ {
+ grp.Validate(handler);
+ }
+ foreach(XmlSchemaNotation ntn in Notations.Values)
+ {
+ ntn.Validate(handler);
+ }
+ }
+
+
+ #region Read
+
+ public static XmlSchema Read(TextReader reader, ValidationEventHandler validationEventHandler)
+ {
+ return Read(new XmlTextReader(reader),validationEventHandler);
+ }
+ public static XmlSchema Read(Stream stream, ValidationEventHandler validationEventHandler)
+ {
+ return Read(new XmlTextReader(stream),validationEventHandler);
+ }
+
+ public static XmlSchema Read(XmlReader rdr, ValidationEventHandler validationEventHandler)
+ {
+ //XmlSerializer xser = new XmlSerializer(typeof(XmlSchema));
+ //return (XmlSchema) xser.Deserialize(reader);
+ XmlSchemaReader reader = new XmlSchemaReader(rdr, validationEventHandler);
+
+ while(reader.ReadNextElement())
+ {
+ switch(reader.NodeType)
+ {
+ case XmlNodeType.Element:
+ if(reader.LocalName == "schema")
+ {
+ XmlSchema schema = new XmlSchema();
+
+ schema.LineNumber = reader.LineNumber;
+ schema.LinePosition = reader.LinePosition;
+ schema.SourceUri = reader.BaseURI;
+
+ ReadAttributes(schema, reader, validationEventHandler);
+ //IsEmptyElement does not behave properly if reader is
+ //positioned at an attribute.
+ reader.MoveToElement();
+ if(!reader.IsEmptyElement)
+ {
+ ReadContent(schema, reader, validationEventHandler);
+ }
+ return schema;
+ }
+ else
+ {
+ //Schema can't be generated. Throw an exception
+ throw new XmlSchemaException("The root element must be schema", null);
+ }
+ default:
+ error(validationEventHandler, "This should never happen. XmlSchema.Read 1 ",null);
+ break;
+ }
+ }
+ throw new XmlSchemaException("The top level schema must have namespace "+XmlSchema.Namespace, null);
+ }
+
+ private static void ReadAttributes(XmlSchema schema, XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ Exception ex;
+
+ reader.MoveToElement();
+ while(reader.MoveToNextAttribute())
+ {
+ switch(reader.Name)
+ {
+ case "attributeFormDefault" :
+ schema.attributeFormDefault = XmlSchemaUtil.ReadFormAttribute(reader,out ex);
+ if(ex != null)
+ error(h, reader.Value + " is not a valid value for attributeFormDefault.", ex);
+ break;
+ case "blockDefault" :
+ schema.blockDefault = XmlSchemaUtil.ReadDerivationAttribute(reader,out ex, "blockDefault");
+ if(ex != null)
+ warn(h, ex.Message, ex);
+ break;
+ case "elementFormDefault":
+ schema.elementFormDefault = XmlSchemaUtil.ReadFormAttribute(reader, out ex);
+ if(ex != null)
+ error(h, reader.Value + " is not a valid value for elementFormDefault.", ex);
+ break;
+ case "finalDefault":
+ schema.finalDefault = XmlSchemaUtil.ReadDerivationAttribute(reader, out ex, "finalDefault");
+ if(ex != null)
+ warn(h, ex.Message , ex);
+ break;
+ case "id":
+ schema.id = reader.Value;
+ break;
+ case "targetNamespace":
+ schema.targetNamespace = reader.Value;
+ break;
+ case "version":
+ schema.version = reader.Value;
+ break;
+ case "xml:lang":
+ schema.language = reader.Value;
+ break;
+ default:
+ if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ error(h, reader.Name + " attribute is not allowed in schema element",null);
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,schema);
+ }
+ break;
+ }
+ }
+ }
+
+ private static void ReadContent(XmlSchema schema, XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ reader.MoveToElement();
+ if(reader.LocalName != "schema" && reader.NamespaceURI != XmlSchema.Namespace && reader.NodeType != XmlNodeType.Element)
+ error(h, "UNREACHABLE CODE REACHED: Method: Schema.ReadContent, " + reader.LocalName + ", " + reader.NamespaceURI,null);
+
+ //(include | import | redefine | annotation)*,
+ //((simpleType | complexType | group | attributeGroup | element | attribute | notation | annotation)*
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchema.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1)
+ {
+ if(reader.LocalName == "include")
+ {
+ XmlSchemaInclude include = XmlSchemaInclude.Read(reader,h);
+ if(include != null)
+ schema.includes.Add(include);
+ continue;
+ }
+ if(reader.LocalName == "import")
+ {
+ XmlSchemaImport import = XmlSchemaImport.Read(reader,h);
+ if(import != null)
+ schema.includes.Add(import);
+ continue;
+ }
+ if(reader.LocalName == "redefine")
+ {
+ XmlSchemaRedefine redefine = XmlSchemaRedefine.Read(reader,h);
+ if(redefine != null)
+ schema.includes.Add(redefine);
+ continue;
+ }
+ if(reader.LocalName == "annotation")
+ {
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ schema.items.Add(annotation);
+ continue;
+ }
+ }
+ if(level <=2)
+ {
+ level = 2;
+ if(reader.LocalName == "simpleType")
+ {
+ XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h);
+ if(stype != null)
+ schema.items.Add(stype);
+ continue;
+ }
+ if(reader.LocalName == "complexType")
+ {
+ XmlSchemaComplexType ctype = XmlSchemaComplexType.Read(reader,h);
+ if(ctype != null)
+ schema.items.Add(ctype);
+ continue;
+ }
+ if(reader.LocalName == "group")
+ {
+ XmlSchemaGroup group = XmlSchemaGroup.Read(reader,h);
+ if(group != null)
+ schema.items.Add(group);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ XmlSchemaAttributeGroup attributeGroup = XmlSchemaAttributeGroup.Read(reader,h);
+ if(attributeGroup != null)
+ schema.items.Add(attributeGroup);
+ continue;
+ }
+ if(reader.LocalName == "element")
+ {
+ XmlSchemaElement element = XmlSchemaElement.Read(reader,h);
+ if(element != null)
+ schema.items.Add(element);
+ continue;
+ }
+ if(reader.LocalName == "attribute")
+ {
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ schema.items.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "notation")
+ {
+ XmlSchemaNotation notation = XmlSchemaNotation.Read(reader,h);
+ if(notation != null)
+ schema.items.Add(notation);
+ continue;
+ }
+ if(reader.LocalName == "annotation")
+ {
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ schema.items.Add(annotation);
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ }
+ #endregion
+
+ #region write
+
+ public void Write(System.IO.Stream stream)
+ {
+ Write(stream,null);
+ }
+ public void Write(System.IO.TextWriter writer)
+ {
+ Write(writer,null);
+ }
+ public void Write(System.Xml.XmlWriter writer)
+ {
+ Write(writer,null);
+ }
+ public void Write(System.IO.Stream stream, System.Xml.XmlNamespaceManager namespaceManager)
+ {
+ Write(new XmlTextWriter(stream,null),namespaceManager);
+ }
+ public void Write(System.IO.TextWriter writer, System.Xml.XmlNamespaceManager namespaceManager)
+ {
+ XmlTextWriter xwriter = new XmlTextWriter(writer);
+ xwriter.Formatting = Formatting.Indented;
+ Write(xwriter,namespaceManager);
+ }
+ public void Write(System.Xml.XmlWriter writer, System.Xml.XmlNamespaceManager namespaceManager)
+ {
+ if(Namespaces == null)
+ {
+ Namespaces = new XmlSerializerNamespaces();
+ }
+ //Add the xml schema namespace.
+ if(Namespaces.Count == 0)
+ {
+ Namespaces.Add("xs", XmlSchema.Namespace);
+ if (TargetNamespace != null && TargetNamespace != String.Empty)
+ Namespaces.Add("tns", TargetNamespace);
+ }
+ if(namespaceManager != null)
+ {
+ foreach(string name in namespaceManager)
+ {
+ //xml and xmlns namespaced are added by default in namespaceManager.
+ //So we should ignore them
+ if(name!="xml" && name != "xmlns")
+ Namespaces.Add(name,namespaceManager.LookupNamespace(name));
+ }
+ }
+
+ XmlSerializer xser = new XmlSerializer(typeof(XmlSchema));
+ xser.Serialize(writer,this,Namespaces);
+ writer.Flush();
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAll.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAll.cs
new file mode 100755
index 00000000000..21e52e7e5b6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAll.cs
@@ -0,0 +1,165 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAll.
+ /// </summary>
+ public class XmlSchemaAll : XmlSchemaGroupBase
+ {
+ private XmlSchemaObjectCollection items;
+ private static string xmlname = "all";
+
+ public XmlSchemaAll()
+ {
+ items = new XmlSchemaObjectCollection();
+ }
+
+ [XmlElement("element",typeof(XmlSchemaElement),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public override XmlSchemaObjectCollection Items
+ {
+ get{ return items; }
+ }
+
+ /// <remarks>
+ /// 1. MaxOccurs must be one. (default is also one)
+ /// 2. MinOccurs must be zero or one.
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ //FIXME: Should we reset the values on error??
+ if(MaxOccurs != Decimal.One)
+ error(h,"maxOccurs must be 1");
+ if(MinOccurs != Decimal.One && MinOccurs != Decimal.Zero)
+ error(h,"minOccurs must be 0 or 1");
+
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);
+
+ foreach(XmlSchemaObject obj in Items)
+ {
+ if(obj is XmlSchemaElement)
+ {
+ XmlSchemaElement elem = (XmlSchemaElement)obj;
+ if(elem.MaxOccurs != Decimal.One && elem.MaxOccurs != Decimal.Zero)
+ {
+ elem.error(h,"The {max occurs} of all the elements of 'all' must be 0 or 1. ");
+ }
+ errorCount += elem.Compile(h,info);
+ }
+ else
+ {
+ error(h,"XmlSchemaAll can only contain Items of type Element");
+ }
+ }
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<all
+ // id = ID
+ // maxOccurs = 1 : 1
+ // minOccurs = (0 | 1) : 1
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, element*)
+ //</all>
+ internal static XmlSchemaAll Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAll all = new XmlSchemaAll();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAll.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ all.LineNumber = reader.LineNumber;
+ all.LinePosition = reader.LinePosition;
+ all.SourceUri = reader.BaseURI;
+
+ //Read Attributes
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ all.Id = reader.Value;
+ }
+ else if(reader.Name == "maxOccurs")
+ {
+ try
+ {
+ all.MaxOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for maxOccurs",e);
+ }
+ }
+ else if(reader.Name == "minOccurs")
+ {
+ try
+ {
+ all.MinOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for minOccurs",e);
+ }
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for all",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,all);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return all;
+
+ //Content: (annotation?, element*)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAll.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ all.Annotation = annotation;
+ continue;
+ }
+ if(level <=2 && reader.LocalName == "element")
+ {
+ level = 2;
+ XmlSchemaElement element = XmlSchemaElement.Read(reader,h);
+ if(element != null)
+ all.items.Add(element);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return all;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotated.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotated.cs
new file mode 100755
index 00000000000..6631dfed480
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotated.cs
@@ -0,0 +1,56 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAnnotated.
+ /// </summary>
+
+ public class XmlSchemaAnnotated : XmlSchemaObject
+ {
+ private XmlSchemaAnnotation annotation;
+ private string id;
+ private XmlAttribute[] unhandledAttributes;
+
+ public XmlSchemaAnnotated()
+ {}
+
+ [System.Xml.Serialization.XmlAttribute("id")]
+ public string Id
+ {
+ get{ return id; }
+ set{ id = value; }
+ }
+
+ [XmlElement("annotation",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnnotation Annotation
+ {
+ get{ return annotation; }
+ set{ annotation = value; }
+ }
+
+ [XmlAnyAttribute]
+ public XmlAttribute[] UnhandledAttributes
+ {
+ get
+ {
+ if(unhandledAttributeList != null)
+ {
+ unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
+ unhandledAttributeList = null;
+ }
+ return unhandledAttributes;
+ }
+ set
+ {
+ unhandledAttributes = value;
+ unhandledAttributeList = null;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotation.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotation.cs
new file mode 100755
index 00000000000..12fe3d26875
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotation.cs
@@ -0,0 +1,145 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAnnotation.
+ /// </summary>
+ public class XmlSchemaAnnotation : XmlSchemaObject
+ {
+ private string id;
+ private XmlSchemaObjectCollection items;
+ private XmlAttribute[] unhandledAttributes;
+ private static string xmlname = "annotation";
+ public XmlSchemaAnnotation()
+ {
+ items = new XmlSchemaObjectCollection();
+ }
+
+ [System.Xml.Serialization.XmlAttribute("id")]
+ public string Id
+ {
+ get{ return id; }
+ set{ id = value; }
+ }
+
+ [XmlElement("appinfo",typeof(XmlSchemaAppInfo),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("documentation",typeof(XmlSchemaDocumentation),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Items
+ {
+ get{ return items; }
+ }
+
+ [XmlAnyAttribute]
+ public XmlAttribute[] UnhandledAttributes
+ {
+ get
+ {
+ if(unhandledAttributeList != null)
+ {
+ unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
+ unhandledAttributeList = null;
+ }
+ return unhandledAttributes;
+ }
+ set
+ {
+ unhandledAttributes = value;
+ unhandledAttributeList = null;
+ }
+ }
+
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ return 0;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return 0;
+ }
+
+ //<annotation
+ // id = ID
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (appinfo | documentation)*
+ //</annotation>
+ internal static XmlSchemaAnnotation Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAnnotation.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ annotation.LineNumber = reader.LineNumber;
+ annotation.LinePosition = reader.LinePosition;
+ annotation.SourceUri = reader.BaseURI;
+
+ //Read Attributes
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ annotation.Id = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for annotation",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,annotation);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return annotation;
+
+ //Content: (appinfo | documentation)*
+ bool skip = false;
+ while(!reader.EOF)
+ {
+ if(skip)
+ skip=false;
+ else
+ reader.ReadNextElement();
+
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAnnotation.Read, name="+reader.Name,null);
+ break;
+ }
+ if(reader.LocalName == "appinfo")
+ {
+ XmlSchemaAppInfo appinfo = XmlSchemaAppInfo.Read(reader,h,out skip);
+ if(appinfo != null)
+ annotation.items.Add(appinfo);
+ continue;
+ }
+ if(reader.LocalName == "documentation")
+ {
+ XmlSchemaDocumentation documentation = XmlSchemaDocumentation.Read(reader,h, out skip);
+ if(documentation != null)
+ annotation.items.Add(documentation);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return annotation;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAny.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAny.cs
new file mode 100755
index 00000000000..6f652481669
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAny.cs
@@ -0,0 +1,192 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+using System.ComponentModel;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAny.
+ /// </summary>
+ public class XmlSchemaAny : XmlSchemaParticle
+ {
+ private string nameSpace;
+ private XmlSchemaContentProcessing processing;
+ private static string xmlname = "any";
+
+ public XmlSchemaAny()
+ {
+ }
+
+ [System.Xml.Serialization.XmlAttribute("namespace")]
+ public string Namespace
+ {
+ get{ return nameSpace; }
+ set{ nameSpace = value; }
+ }
+
+ [DefaultValue(XmlSchemaContentProcessing.None)]
+ [System.Xml.Serialization.XmlAttribute("processContents")]
+ public XmlSchemaContentProcessing ProcessContents
+ {
+ get{ return processing; }
+ set{ processing = value; }
+ }
+
+ /// <remarks>
+ /// 1. id must be of type ID
+ /// 2. namespace can have one of the following values:
+ /// a) ##any or ##other
+ /// b) list of anyURI and ##targetNamespace and ##local
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ //define ##any=1,##other=2,##targetNamespace=4,##local=8,anyURI=16
+ int nscount = 0;
+ string[] nslist = XmlSchemaUtil.SplitList(Namespace);
+ foreach(string ns in nslist)
+ {
+ switch(ns)
+ {
+ case "##any":
+ nscount |= 1;
+ break;
+ case "##other":
+ nscount |= 2;
+ break;
+ case "##targetNamespace":
+ nscount |= 4;
+ break;
+ case "##local":
+ nscount |= 8;
+ break;
+ default:
+ if(!XmlSchemaUtil.CheckAnyUri(ns))
+ error(h,"the namespace is not a valid anyURI");
+ else
+ nscount |= 16;
+ break;
+ }
+ }
+ if((nscount&1) == 1 && nscount != 1)
+ error(h,"##any if present must be the only namespace attribute");
+ if((nscount&2) == 2 && nscount != 2)
+ error(h,"##other if present must be the only namespace attribute");
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<any
+ // id = ID
+ // maxOccurs = (nonNegativeInteger | unbounded) : 1
+ // minOccurs = nonNegativeInteger : 1
+ // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any
+ // processContents = (lax | skip | strict) : strict
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</any>
+ internal static XmlSchemaAny Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAny any = new XmlSchemaAny();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAny.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ any.LineNumber = reader.LineNumber;
+ any.LinePosition = reader.LinePosition;
+ any.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ any.Id = reader.Value;
+ }
+ else if(reader.Name == "maxOccurs")
+ {
+ try
+ {
+ any.MaxOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for maxOccurs",e);
+ }
+ }
+ else if(reader.Name == "minOccurs")
+ {
+ try
+ {
+ any.MinOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for minOccurs", e);
+ }
+ }
+ else if(reader.Name == "namespace")
+ {
+ any.nameSpace = reader.Value;
+ }
+ else if(reader.Name == "processContents")
+ {
+ Exception innerex;
+ any.processing = XmlSchemaUtil.ReadProcessingAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for processContents",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for any",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,any);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return any;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAny.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ any.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return any;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnyAttribute.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnyAttribute.cs
new file mode 100755
index 00000000000..fb1a515e5ca
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnyAttribute.cs
@@ -0,0 +1,169 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.ComponentModel;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAnyAttribute.
+ /// </summary>
+ public class XmlSchemaAnyAttribute : XmlSchemaAnnotated
+ {
+ private string nameSpace;
+ private XmlSchemaContentProcessing processing;
+ private static string xmlname = "anyAttribute";
+
+ public XmlSchemaAnyAttribute()
+ {
+ }
+
+ [System.Xml.Serialization.XmlAttribute("namespace")]
+ public string Namespace
+ {
+ get{ return nameSpace; }
+ set{ nameSpace = value; }
+ }
+
+ [DefaultValue(XmlSchemaContentProcessing.None)]
+ [System.Xml.Serialization.XmlAttribute("processContents")]
+ public XmlSchemaContentProcessing ProcessContents
+ {
+ get{ return processing; }
+ set{ processing = value; }
+ }
+
+ /// <remarks>
+ /// 1. id must be of type ID
+ /// 2. namespace can have one of the following values:
+ /// a) ##any or ##other
+ /// b) list of anyURI and ##targetNamespace and ##local
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ //define ##any=1,##other=2,##targetNamespace=4,##local=8,anyURI=16
+ int nscount = 0;
+ string[] nslist = XmlSchemaUtil.SplitList(Namespace);
+ foreach(string ns in nslist)
+ {
+ switch(ns)
+ {
+ case "##any":
+ nscount |= 1;
+ break;
+ case "##other":
+ nscount |= 2;
+ break;
+ case "##targetNamespace":
+ nscount |= 4;
+ break;
+ case "##local":
+ nscount |= 8;
+ break;
+ default:
+ if(!XmlSchemaUtil.CheckAnyUri(ns))
+ error(h,"the namespace is not a valid anyURI");
+ else
+ nscount |= 16;
+ break;
+ }
+ }
+ if((nscount&1) == 1 && nscount != 1)
+ error(h,"##any if present must be the only namespace attribute");
+ if((nscount&2) == 2 && nscount != 2)
+ error(h,"##other if present must be the only namespace attribute");
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<anyAttribute
+ // id = ID
+ // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any
+ // processContents = (lax | skip | strict) : strict
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</anyAttribute>
+ internal static XmlSchemaAnyAttribute Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAnyAttribute any = new XmlSchemaAnyAttribute();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAnyAttribute.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ any.LineNumber = reader.LineNumber;
+ any.LinePosition = reader.LinePosition;
+ any.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ any.Id = reader.Value;
+ }
+ else if(reader.Name == "namespace")
+ {
+ any.nameSpace = reader.Value;
+ }
+ else if(reader.Name == "processContents")
+ {
+ Exception innerex;
+ any.processing = XmlSchemaUtil.ReadProcessingAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for processContents",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for anyAttribute",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,any);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return any;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAnyAttribute.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ any.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return any;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAppInfo.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAppInfo.cs
new file mode 100755
index 00000000000..da66837c504
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAppInfo.cs
@@ -0,0 +1,91 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAppInfo.
+ /// </summary>
+ public class XmlSchemaAppInfo : XmlSchemaObject
+ {
+ private XmlNode[] markup;
+ private string source;
+
+ public XmlSchemaAppInfo()
+ {
+ }
+
+ [System.Xml.Serialization.XmlAttribute("source")]
+ public string Source
+ {
+ get{ return source; }
+ set{ source = value; }
+ }
+
+ [XmlAnyElement]
+ [XmlText]
+ public XmlNode[] Markup
+ {
+ get{ return markup; }
+ set{ markup = value; }
+ }
+
+ //<appinfo
+ // source = anyURI>
+ // Content: ({any})*
+ //</appinfo>
+ internal static XmlSchemaAppInfo Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip)
+ {
+ skip = false;
+ XmlSchemaAppInfo appinfo = new XmlSchemaAppInfo();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "appinfo")
+ {
+ error(h,"Should not happen :1: XmlSchemaAppInfo.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ appinfo.LineNumber = reader.LineNumber;
+ appinfo.LinePosition = reader.LinePosition;
+ appinfo.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "source")
+ {
+ appinfo.source = reader.Value;
+ }
+ else
+ {
+ error(h,reader.Name + " is not a valid attribute for appinfo",null);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return appinfo;
+
+ //Content {any}*
+ //FIXME: This is a pure Quick Hack; There must be a another method;
+ XmlDocument xmldoc = new XmlDocument();
+ xmldoc.AppendChild(xmldoc.ReadNode(reader));
+ XmlNode root = xmldoc.FirstChild;
+ if(root != null && root.ChildNodes != null)
+ {
+ appinfo.Markup = new XmlNode[root.ChildNodes.Count];
+ for(int i=0;i<root.ChildNodes.Count;i++)
+ {
+ appinfo.Markup[i] = root.ChildNodes[i];
+ }
+ }
+ if(reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement)
+ skip = true;
+ return appinfo;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs
new file mode 100755
index 00000000000..a7e82b6db3f
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs
@@ -0,0 +1,435 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.ComponentModel;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAttribute.
+ /// </summary>
+ public class XmlSchemaAttribute : XmlSchemaAnnotated
+ {
+ private object attributeType;
+ private string defaultValue;
+ private string fixedValue;
+ private XmlSchemaForm form;
+ private string name;
+ private XmlQualifiedName qualifiedName;
+ private XmlQualifiedName refName;
+ private XmlSchemaSimpleType schemaType;
+ private XmlQualifiedName schemaTypeName;
+ private XmlSchemaUse use;
+ //Compilation fields
+ internal bool parentIsSchema = false;
+ private static string xmlname = "attribute";
+
+ public XmlSchemaAttribute()
+ {
+ //FIXME: Docs says the default is optional.
+ //Whereas the MS implementation has default None.
+ form = XmlSchemaForm.None;
+ use = XmlSchemaUse.None;
+ schemaTypeName = XmlQualifiedName.Empty;
+ qualifiedName = XmlQualifiedName.Empty;
+ refName = XmlQualifiedName.Empty;
+ }
+
+ // Properties
+ #region Properties
+
+ [DefaultValue(null)]
+ [System.Xml.Serialization.XmlAttribute("default")]
+ public string DefaultValue
+ {
+ get{ return defaultValue;}
+ set
+ { // Default Value and fixed Value are mutually exclusive
+ fixedValue = null;
+ defaultValue = value;
+ }
+ }
+
+ [DefaultValue(null)]
+ [System.Xml.Serialization.XmlAttribute("fixed")]
+ public string FixedValue
+ {
+ get{ return fixedValue;}
+ set
+ { // Default Value and fixed Value are mutually exclusive
+ defaultValue = null;
+ fixedValue = value;
+ }
+ }
+
+ [DefaultValue(XmlSchemaForm.None)]
+ [System.Xml.Serialization.XmlAttribute("form")]
+ public XmlSchemaForm Form
+ {
+ get{ return form;}
+ set{ form = value;}
+ }
+
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name;}
+ set
+ {
+ name = value;
+ }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("ref")]
+ public XmlQualifiedName RefName
+ {
+ get{ return refName;}
+ set
+ {
+ refName = value;
+ }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("type")]
+ public XmlQualifiedName SchemaTypeName
+ {
+ get{ return schemaTypeName;}
+ set{ schemaTypeName = value;}
+ }
+
+ [XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaSimpleType SchemaType
+ {
+ get{ return schemaType;}
+ set{ schemaType = value;}
+ }
+
+ [DefaultValue(XmlSchemaUse.None)]
+ [System.Xml.Serialization.XmlAttribute("use")]
+ public XmlSchemaUse Use
+ {
+ get{ return use;}
+ set{ use = value;}
+ }
+
+ [XmlIgnore]
+ public XmlQualifiedName QualifiedName
+ {
+ get{ return qualifiedName;}
+ }
+
+ [XmlIgnore]
+ public object AttributeType
+ { //FIXME: This is not correct. Is it?
+ get{ return attributeType; }
+ }
+
+ #endregion
+
+ /// <remarks>
+ /// For an attribute:
+ /// a) If the parent is schema
+ /// 1-5 are from <xs:complexType name="topLevelAttribute"> in the Schema for Schema
+ /// 6-8 are from "Constraints on XML Representations of Attribute Declarations"
+ /// 9-10 are from "Attribute Declaration Schema Component"
+ /// 11-16 are from "Constraints on Attribute Declaration Schema Components"
+ /// 1. ref must be absent
+ /// 2. form must be absent
+ /// 3. use must be absent
+ /// 4. name must be present and of type NCName
+ /// 5. *NO CHECK REQUIRED* Only simple types and annotation are allowed as content
+ /// 6. default and fixed must not both be present.
+ /// 7. *NO CHECK REQUIRED* If default and use are both present... (Not possible since use is absent)
+ /// 8. type and <simpleType> must not both be present.
+ /// 9. Target Namespace should be schema's targetnamespace or absent
+ /// 10. Type Definiton coressponds to <simpletype> element, or type value, or absent
+ /// 11. *TO UNDERSTAND* Missing Sub-components
+ /// 12. value constraint must be of the same datatype as of type
+ /// 13. if the type definition is ID then there should be no value constraint.
+ /// 14. name must not be xmlns
+ /// 15. Targetnamespace must not be xsi. This implies the target namespace of schema can't be xsi if toplevel attributes are used.
+ /// 16. *Exception to rule 15* inbuilt attributes: xsi:nil, xsi:type, xsi:schemaLocation, xsi: noNamespaceSchemaLocation
+ /// b) If the parent is complextype and ref is not set
+ /// 1. name must be present and of type NCName.
+ /// 2. type and <simpleType> must not both be present.
+ /// 3. default and fixed must not both be present.
+ /// 4. If default and use are both present, use must have the ·actual value· optional.
+ /// 5. name must not be xmlns
+ /// 6. Targetnamespace must not be xsi.
+ /// 7. *Exception to rule 15* inbuilt attributes: xsi:nil, xsi:type, xsi:schemaLocation, xsi: noNamespaceSchemaLocation
+ /// 8. If form has actual value qualified or the schema's formdefault is qualified, targetnamespace
+ /// is same as schema's target namespace, otherwise absent.
+ /// c) if the parent is not schema and ref is set
+ /// 1. name must not be present
+ /// 2. all of <simpleType>, form and type must be absent.
+ /// 3. default and fixed must not both be present.
+ /// 4. If default and use are both present, use must have the ·actual value· optional.
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ if(parentIsSchema)//a
+ {
+ if(RefName!= null && !RefName.IsEmpty) // a.1
+ error(h,"ref must be absent in the top level <attribute>");
+
+ if(Form != XmlSchemaForm.None) // a.2
+ error(h,"form must be absent in the top level <attribute>");
+
+ if(Use != XmlSchemaUse.None) // a.3
+ error(h,"use must be absent in the top level <attribute>");
+
+ // TODO: a.10, a.11, a.12, a.13
+ CompileCommon(h,info, true);
+ }
+ else // local
+ {
+ //FIXME: How to Use of AttributeFormDefault????
+ if(RefName == null || RefName.IsEmpty)
+ {
+ //TODO: b.8
+ CompileCommon(h,info, true);
+ }
+ else
+ {
+ if(this.name != null)
+ error(h,"name must be absent if ref is present");
+ if(this.form != XmlSchemaForm.None)
+ error(h,"form must be absent if ref is present");
+ if(this.schemaType != null)
+ error(h,"simpletype must be absent if ref is present");
+ if(this.schemaTypeName != null && !this.schemaTypeName.IsEmpty)
+ error(h,"type must be absent if ref is present");
+ CompileCommon(h,info,false);
+ }
+ }
+
+ return errorCount;
+ }
+
+ private void CompileCommon(ValidationEventHandler h, XmlSchemaInfo info, bool refIsNotPresent)
+ {
+ if(refIsNotPresent)
+ {
+ if(Name == null) //a.4, b.1,
+ error(h,"Required attribute name must be present");
+ else if(!XmlSchemaUtil.CheckNCName(Name)) // a.4.2, b1.2
+ error(h,"attribute name must be NCName");
+ else if(Name == "xmlns") // a.14 , b5
+ error(h,"attribute name must not be xmlns");
+ else
+ qualifiedName = new XmlQualifiedName(Name, info.TargetNamespace);
+
+ if(SchemaType != null)
+ {
+ if(SchemaTypeName != null && !SchemaTypeName.IsEmpty) // a.8
+ error(h,"attribute can't have both a type and <simpleType> content");
+
+ errorCount += SchemaType.Compile(h,info);
+ }
+
+ if(SchemaTypeName != null && !XmlSchemaUtil.CheckQName(SchemaTypeName))
+ error(h,SchemaTypeName+" is not a valid QName");
+ }
+ else
+ {
+ if(RefName == null || RefName.IsEmpty)
+ error(h,"Error: Should Never Happen. refname must be present");
+ else
+ qualifiedName = RefName;
+ }
+
+ if(info.TargetNamespace == XmlSchema.InstanceNamespace && Name != "nil" && Name != "type"
+ && Name != "schemaLocation" && Name != "noNamespaceSchemaLocation") // a.15, a.16
+ error(h,"targetNamespace can't be " + XmlSchema.InstanceNamespace);
+
+ if(DefaultValue != null && FixedValue != null) // a.6, b.3, c.3
+ error(h,"default and fixed must not both be present in an Attribute");
+
+ if(DefaultValue != null && Use != XmlSchemaUse.None && Use != XmlSchemaUse.Optional)
+ error(h,"if default is present, use must be optional");
+
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);
+ }
+
+ /// <summary>
+ /// Schema Component:
+ /// QName, SimpleType, Scope, Default|Fixed, annotation
+ /// </summary>
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(isCompiled)
+ return errorCount;
+
+ //If Parent is schema:
+ if(parentIsSchema)
+ {
+ if(SchemaType != null)
+ {
+ errorCount += SchemaType.Validate(h, info);
+ attributeType = SchemaType;
+ }
+ else if(SchemaTypeName != null && !SchemaTypeName.IsEmpty)
+ {
+ //First Try to get a Inbuilt DataType
+ XmlSchemaDatatype dtype = XmlSchemaDatatype.GetType(SchemaTypeName);
+ if(dtype != null)
+ {
+ attributeType = dtype;
+ }
+ else
+ {
+ XmlSchemaObject obj = info.SchemaTypes[SchemaTypeName];
+
+ if(obj is XmlSchemaSimpleType)
+ {
+ XmlSchemaSimpleType stype = (XmlSchemaSimpleType) obj;
+ errorCount += stype.Validate(h, info);
+ attributeType = stype;
+ }
+ else if(attributeType == null)
+ error(h,"The type '"+ SchemaTypeName +"' is not defined in the schema");
+ else if(attributeType is XmlSchemaComplexType)
+ error(h,"An attribute can't have complexType Content");
+ else
+ error(h, "Should Never Happen. Illegal content in SchemaTypes");
+ }
+ }
+ else
+ {
+ error(h,"Should Never Happen. Attribute SimpleType Not set. Should have been caught in the Compile() phase");
+ }
+ }
+ else
+ {
+ //TODO: Local Attribute Validation
+ }
+ isCompiled = true;
+ return errorCount;
+ }
+ //<attribute
+ // default = string
+ // fixed = string
+ // form = (qualified | unqualified)
+ // id = ID
+ // name = NCName
+ // ref = QName
+ // type = QName
+ // use = (optional | prohibited | required) : optional
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (simpleType?))
+ //</attribute>
+ internal static XmlSchemaAttribute Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAttribute attribute = new XmlSchemaAttribute();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAttribute.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ attribute.LineNumber = reader.LineNumber;
+ attribute.LinePosition = reader.LinePosition;
+ attribute.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "default")
+ {
+ attribute.defaultValue = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ attribute.fixedValue = reader.Value;
+ }
+ else if(reader.Name == "form")
+ {
+ Exception innerex;
+ attribute.form = XmlSchemaUtil.ReadFormAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for form attribute", innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ attribute.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ attribute.name = reader.Value;
+ }
+ else if(reader.Name == "ref")
+ {
+ Exception innerex;
+ attribute.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for ref attribute",innerex);
+ }
+ else if(reader.Name == "type")
+ {
+ Exception innerex;
+ attribute.schemaTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for type attribute",innerex);
+ }
+ else if(reader.Name == "use")
+ {
+ Exception innerex;
+ attribute.use = XmlSchemaUtil.ReadUseAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for use attribute", innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for attribute",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,attribute);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return attribute;
+
+ // Content: (annotation?, (simpleType?))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAttribute.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ attribute.Annotation = annotation;
+ continue;
+ }
+ if(level <=2 && reader.LocalName == "simpleType")
+ {
+ level = 3;
+ XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h);
+ if(stype != null)
+ attribute.schemaType = stype;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return attribute;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroup.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroup.cs
new file mode 100755
index 00000000000..ab5d1da1afe
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroup.cs
@@ -0,0 +1,208 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAttributeGroup.
+ /// </summary>
+ public class XmlSchemaAttributeGroup : XmlSchemaAnnotated
+ {
+ private XmlSchemaAnyAttribute any;
+ private XmlSchemaObjectCollection attributes;
+ private string name;
+ private XmlSchemaAttributeGroup redefined;
+ private XmlQualifiedName qualifiedName;
+ private static string xmlname = "attributeGroup";
+
+ public XmlSchemaAttributeGroup()
+ {
+ attributes = new XmlSchemaObjectCollection();
+ }
+
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name;}
+ set{ name = value;}
+ }
+
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Attributes
+ {
+ get{ return attributes;}
+ }
+
+ [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnyAttribute AnyAttribute
+ {
+ get{ return any;}
+ set{ any = value;}
+ }
+
+ //Undocumented property
+ [XmlIgnore]
+ public XmlSchemaAttributeGroup RedefinedAttributeGroup
+ {
+ get{ return redefined;}
+ }
+
+ [XmlIgnore]
+ internal XmlQualifiedName QualifiedName
+ {
+ get{ return qualifiedName;}
+ }
+
+ /// <remarks>
+ /// An Attribute group can only be defined as a child of XmlSchema or in XmlSchemaRedefine.
+ /// The other attributeGroup has type XmlSchemaAttributeGroupRef.
+ /// 1. Name must be present
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ if(this.Name == null) //1
+ error(h,"Name is required in top level simpletype");
+ else if(!XmlSchemaUtil.CheckNCName(this.Name)) // b.1.2
+ error(h,"name attribute of a simpleType must be NCName");
+ else
+ this.qualifiedName = new XmlQualifiedName(this.Name,info.TargetNamespace);
+
+ if(this.AnyAttribute != null)
+ {
+ errorCount += this.AnyAttribute.Compile(h,info);
+ }
+
+ foreach(XmlSchemaObject obj in Attributes)
+ {
+ if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ errorCount += attr.Compile(h, info);
+ }
+ else if(obj is XmlSchemaAttributeGroupRef)
+ {
+ XmlSchemaAttributeGroupRef gref = (XmlSchemaAttributeGroupRef) obj;
+ errorCount += gref.Compile(h, info);
+ }
+ else
+ {
+ error(h,"invalid type of object in Attributes property");
+ }
+ }
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<attributeGroup
+ // id = ID
+ // name = NCName
+ // ref = QName // Not present in this class.
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?))
+ //</attributeGroup>
+ internal static XmlSchemaAttributeGroup Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAttributeGroup attrgrp = new XmlSchemaAttributeGroup();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAttributeGroup.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ attrgrp.LineNumber = reader.LineNumber;
+ attrgrp.LinePosition = reader.LinePosition;
+ attrgrp.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ attrgrp.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ attrgrp.name = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for attributeGroup in this context",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,attrgrp);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return attrgrp;
+
+ //Content: 1.annotation?, 2.(attribute | attributeGroup)*, 3.anyAttribute?
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAttributeGroup.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ attrgrp.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "attribute")
+ {
+ level = 2;
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ attrgrp.Attributes.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ level = 2;
+ XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h);
+ if(attr != null)
+ attrgrp.attributes.Add(attr);
+ continue;
+ }
+ }
+ if(level <= 3 && reader.LocalName == "anyAttribute")
+ {
+ level = 4;
+ XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h);
+ if(anyattr != null)
+ attrgrp.AnyAttribute = anyattr;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return attrgrp;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroupRef.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroupRef.cs
new file mode 100755
index 00000000000..0fb4a4261aa
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroupRef.cs
@@ -0,0 +1,126 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAttributeGroupRef.
+ /// </summary>
+ public class XmlSchemaAttributeGroupRef : XmlSchemaAnnotated
+ {
+ private XmlQualifiedName refName;
+ private static string xmlname = "attributeGroup";
+ public XmlSchemaAttributeGroupRef()
+ {
+ refName = XmlQualifiedName.Empty;
+ }
+
+ [System.Xml.Serialization.XmlAttribute("ref")]
+ public XmlQualifiedName RefName
+ {
+ get{ return refName; }
+ set{ refName = value; }
+ }
+
+ /// <remarks>
+ /// 1. ref must be present
+ /// 2. The element must be empty. ?? FIXME: Is this correct or annotation is permitted?
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+ if(RefName == null || RefName.IsEmpty)
+ error(h, "ref must be present");
+ else if(!XmlSchemaUtil.CheckQName(RefName))
+ error(h, "ref must be a valid qname");
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+// if(this.Annotation != null)
+// error(h, "attributegroup with a ref can't have any content");
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<attributeGroup
+ // id = ID
+ // ref = QName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</attributeGroup>
+ internal static XmlSchemaAttributeGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAttributeGroupRef attrgrp = new XmlSchemaAttributeGroupRef();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ attrgrp.LineNumber = reader.LineNumber;
+ attrgrp.LinePosition = reader.LinePosition;
+ attrgrp.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ attrgrp.Id = reader.Value;
+ }
+ else if(reader.Name == "ref")
+ {
+ Exception innerex;
+ attrgrp.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for ref attribute",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for attributeGroup in this context",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,attrgrp);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return attrgrp;
+ int level = 1;
+
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ attrgrp.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return attrgrp;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaChoice.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaChoice.cs
new file mode 100755
index 00000000000..040de9d9719
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaChoice.cs
@@ -0,0 +1,203 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAll.
+ /// </summary>
+ public class XmlSchemaChoice : XmlSchemaGroupBase
+ {
+ private XmlSchemaObjectCollection items;
+ private static string xmlname = "choice";
+
+ public XmlSchemaChoice()
+ {
+ items = new XmlSchemaObjectCollection();
+ }
+
+ [XmlElement("element",typeof(XmlSchemaElement),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("any",typeof(XmlSchemaAny),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public override XmlSchemaObjectCollection Items
+ {
+ get{ return items; }
+ }
+
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ //FIXME: Should we reset the values
+ if(MinOccurs > MaxOccurs)
+ error(h,"minOccurs must be less than or equal to maxOccurs");
+
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);
+
+ foreach(XmlSchemaObject obj in Items)
+ {
+ if(obj is XmlSchemaElement)
+ {
+ errorCount += ((XmlSchemaElement)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaGroupRef)
+ {
+ errorCount += ((XmlSchemaGroupRef)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaChoice)
+ {
+ errorCount += ((XmlSchemaChoice)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaSequence)
+ {
+ errorCount += ((XmlSchemaSequence)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaAny)
+ {
+ errorCount += ((XmlSchemaAny)obj).Compile(h,info);
+ }
+ }
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<choice
+ // id = ID
+ // maxOccurs = (nonNegativeInteger | unbounded) : 1
+ // minOccurs = nonNegativeInteger : 1
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (element | group | choice | sequence | any)*)
+ //</choice>
+ internal static XmlSchemaChoice Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaChoice choice = new XmlSchemaChoice();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaChoice.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ choice.LineNumber = reader.LineNumber;
+ choice.LinePosition = reader.LinePosition;
+ choice.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ choice.Id = reader.Value;
+ }
+ else if(reader.Name == "maxOccurs")
+ {
+ try
+ {
+ choice.MaxOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for maxOccurs",e);
+ }
+ }
+ else if(reader.Name == "minOccurs")
+ {
+ try
+ {
+ choice.MinOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for minOccurs",e);
+ }
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for choice",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,choice);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return choice;
+
+ // Content: (annotation?, (element | group | choice | sequence | any)*)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaChoice.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ choice.Annotation = annotation;
+ continue;
+ }
+ if(level <=2)
+ {
+ if(reader.LocalName == "element")
+ {
+ level = 2;
+ XmlSchemaElement element = XmlSchemaElement.Read(reader,h);
+ if(element != null)
+ choice.items.Add(element);
+ continue;
+ }
+ if(reader.LocalName == "group")
+ {
+ level = 2;
+ XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h);
+ if(group != null)
+ choice.items.Add(group);
+ continue;
+ }
+ if(reader.LocalName == "choice")
+ {
+ level = 2;
+ XmlSchemaChoice ch = XmlSchemaChoice.Read(reader,h);
+ if(ch != null)
+ choice.items.Add(ch);
+ continue;
+ }
+ if(reader.LocalName == "sequence")
+ {
+ level = 2;
+ XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h);
+ if(sequence != null)
+ choice.items.Add(sequence);
+ continue;
+ }
+ if(reader.LocalName == "any")
+ {
+ level = 2;
+ XmlSchemaAny any = XmlSchemaAny.Read(reader,h);
+ if(any != null)
+ choice.items.Add(any);
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return choice;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollection.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollection.cs
new file mode 100755
index 00000000000..57f73fc72b8
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollection.cs
@@ -0,0 +1,130 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+using System.Xml;
+
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaCollection.
+ /// </summary>
+ public sealed class XmlSchemaCollection : ICollection, IEnumerable
+ {
+ //private fields
+ private Hashtable htable;
+ private Hashtable uriTable;
+ private XmlNameTable ntable;
+
+ public XmlSchemaCollection()
+ : this (new NameTable ())
+ {
+ }
+
+ public XmlSchemaCollection(XmlNameTable nametable)
+ {
+ htable = new Hashtable();
+ uriTable = new Hashtable ();
+ ntable = nametable;
+ }
+
+ //properties
+ public int Count
+ {
+ get
+ {
+ return this.htable.Count;
+ }
+ }
+ public XmlNameTable NameTable
+ {
+ get
+ {
+ return this.ntable;
+ }
+ }
+ public XmlSchema this[ string ns ]
+ {
+ get
+ {
+ return (XmlSchema) this.htable[ns];
+ }
+ }
+
+ // Events
+ public event ValidationEventHandler ValidationEventHandler;
+
+ // Methods
+ [MonoTODO]
+ public XmlSchema Add(string ns, XmlReader reader)
+ {
+ if (reader == null)
+ throw new ArgumentNullException ("reader");
+
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlSchema Add(string ns, string uri)
+ {
+ if (uri == null || uri == String.Empty)
+ throw new ArgumentNullException ("uri");
+
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlSchema Add(XmlSchema schema)
+ {
+ if (schema == null)
+ throw new ArgumentNullException ("schema");
+
+ throw new NotImplementedException ();
+ }
+
+ public void Add(XmlSchemaCollection schema)
+ {
+ if (schema == null)
+ throw new ArgumentNullException ("schema");
+
+ foreach (XmlSchema s in schema)
+ Add (s);
+ }
+
+ public bool Contains(string ns)
+ {
+ return this.htable.Contains(ns);
+ }
+ public bool Contains(XmlSchema schema)
+ {
+ return this.htable.Contains(schema.TargetNamespace);
+ }
+ public void CopyTo(XmlSchema[] array, int index)
+ {
+
+ }
+ public XmlSchemaCollectionEnumerator GetEnumerator()
+ {
+ return new XmlSchemaCollectionEnumerator(this.htable);
+ }
+
+ //assembly Methods
+ [MonoTODO]
+ void ICollection.CopyTo(Array array, int index)
+ {
+ }
+ bool ICollection.IsSynchronized
+ {
+ get { return false; }
+ }
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return this.htable.GetEnumerator();
+ }
+ Object ICollection.SyncRoot
+ {
+ get { return this; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollectionEnumerator.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollectionEnumerator.cs
new file mode 100755
index 00000000000..3130c3094ac
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollectionEnumerator.cs
@@ -0,0 +1,47 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaCollectionEnumerator.
+ /// </summary>
+ public sealed class XmlSchemaCollectionEnumerator : IEnumerator
+ {
+ private IDictionaryEnumerator xenum;
+ internal XmlSchemaCollectionEnumerator(Hashtable htable)
+ {
+ this.xenum = htable.GetEnumerator();
+ }
+ // Properties
+ public XmlSchema Current
+ {
+ get
+ {
+ return (XmlSchema) xenum.Current;
+ }
+ }
+ // Methods
+ public bool MoveNext()
+ {
+ return xenum.MoveNext();
+ }
+
+ //Explicit Interface implementation
+ bool IEnumerator.MoveNext()
+ {
+ return xenum.MoveNext();
+ }
+ void IEnumerator.Reset()
+ {
+ xenum.Reset();
+ }
+ object IEnumerator.Current
+ {
+ get{return (XmlSchema) xenum.Current;}
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContent.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContent.cs
new file mode 100755
index 00000000000..45b07b3b1f0
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContent.cs
@@ -0,0 +1,162 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaComplexContent.
+ /// </summary>
+ public class XmlSchemaComplexContent : XmlSchemaContentModel
+ {
+ private XmlSchemaContent content;
+ private bool isMixed;
+ private static string xmlname = "complexContent";
+
+ public XmlSchemaComplexContent()
+ {}
+
+ [System.Xml.Serialization.XmlAttribute("mixed")]
+ public bool IsMixed
+ {
+ get{ return isMixed; }
+ set{ isMixed = value; }
+ }
+
+ [XmlElement("restriction",typeof(XmlSchemaComplexContentRestriction),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("extension",typeof(XmlSchemaComplexContentExtension),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public override XmlSchemaContent Content
+ {
+ get{ return content; }
+ set{ content = value; }
+ }
+
+ /// <remarks>
+ /// 1. Content must be present
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(Content == null)
+ {
+ error(h, "Content must be present in a complexContent");
+ }
+ else
+ {
+ if(Content is XmlSchemaComplexContentRestriction)
+ {
+ XmlSchemaComplexContentRestriction xscr = (XmlSchemaComplexContentRestriction) Content;
+ errorCount += xscr.Compile(h,info);
+ }
+ else if(Content is XmlSchemaComplexContentExtension)
+ {
+ XmlSchemaComplexContentExtension xsce = (XmlSchemaComplexContentExtension) Content;
+ errorCount += xsce.Compile(h,info);
+ }
+ else
+ error(h,"complexContent can't have any value other than restriction or extention");
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<complexContent
+ // id = ID
+ // mixed = boolean
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (restriction | extension))
+ //</complexContent>
+ internal static XmlSchemaComplexContent Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaComplexContent complex = new XmlSchemaComplexContent();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexContent.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ complex.LineNumber = reader.LineNumber;
+ complex.LinePosition = reader.LinePosition;
+ complex.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ complex.Id = reader.Value;
+ }
+ else if(reader.Name == "mixed")
+ {
+ Exception innerex;
+ complex.isMixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h,reader.Value + " is an invalid value for mixed",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for complexContent",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,complex);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return complex;
+ //Content: (annotation?, (restriction | extension))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaComplexContent.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ complex.Annotation = annotation;
+ continue;
+ }
+ if(level <=2)
+ {
+ if(reader.LocalName == "restriction")
+ {
+ level = 3;
+ XmlSchemaComplexContentRestriction restriction = XmlSchemaComplexContentRestriction.Read(reader,h);
+ if(restriction != null)
+ complex.content = restriction;
+ continue;
+ }
+ if(reader.LocalName == "extension")
+ {
+ level = 3;
+ XmlSchemaComplexContentExtension extension = XmlSchemaComplexContentExtension.Read(reader,h);
+ if(extension != null)
+ complex.content = extension;
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return complex;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentExtension.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentExtension.cs
new file mode 100755
index 00000000000..4deced9326a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentExtension.cs
@@ -0,0 +1,254 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaComplexContentExtension.
+ /// </summary>
+ public class XmlSchemaComplexContentExtension : XmlSchemaContent
+ {
+ private XmlSchemaAnyAttribute any;
+ private XmlSchemaObjectCollection attributes;
+ private XmlQualifiedName baseTypeName;
+ private XmlSchemaParticle particle;
+ private static string xmlname = "extension";
+
+ public XmlSchemaComplexContentExtension()
+ {
+ attributes = new XmlSchemaObjectCollection();
+ baseTypeName = XmlQualifiedName.Empty;
+ }
+
+ [System.Xml.Serialization.XmlAttribute("base")]
+ public XmlQualifiedName BaseTypeName
+ {
+ get{ return baseTypeName; }
+ set{ baseTypeName = value; }
+ }
+
+ [XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaParticle Particle
+ {
+ get{ return particle; }
+ set{ particle = value; }
+ }
+
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Attributes
+ {
+ get{ return attributes; }
+ }
+
+ [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnyAttribute AnyAttribute
+ {
+ get{ return any; }
+ set{ any = value;}
+ }
+
+ /// <remarks>
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(BaseTypeName == null || BaseTypeName.IsEmpty)
+ {
+ error(h, "base must be present and a QName");
+ }
+ else if(!XmlSchemaUtil.CheckQName(BaseTypeName))
+ error(h,"BaseTypeName is not a valid XmlQualifiedName");
+
+ if(this.AnyAttribute != null)
+ {
+ errorCount += AnyAttribute.Compile(h,info);
+ }
+
+ foreach(XmlSchemaObject obj in Attributes)
+ {
+ if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ errorCount += attr.Compile(h,info);
+ }
+ else if(obj is XmlSchemaAttributeGroupRef)
+ {
+ XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;
+ errorCount += atgrp.Compile(h,info);
+ }
+ else
+ error(h,obj.GetType() +" is not valid in this place::ComplexConetnetExtension");
+ }
+
+ if(Particle != null)
+ {
+ if(Particle is XmlSchemaGroupRef)
+ {
+ errorCount += ((XmlSchemaGroupRef)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaAll)
+ {
+ errorCount += ((XmlSchemaAll)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaChoice)
+ {
+ errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaSequence)
+ {
+ errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);
+ }
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<extension
+ // base = QName
+ // id = ID
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))
+ //</extension>
+ internal static XmlSchemaComplexContentExtension Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaComplexContentExtension extension = new XmlSchemaComplexContentExtension();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexContentExtension.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ extension.LineNumber = reader.LineNumber;
+ extension.LinePosition = reader.LinePosition;
+ extension.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "base")
+ {
+ Exception innerex;
+ extension.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for base attribute",innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ extension.Id = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for extension",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,extension);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return extension;
+ //Content: 1. annotation?,
+ // (2.(group | all | choice | sequence)?, (3.(attribute | attributeGroup)*, 4.anyAttribute?)))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaComplexContentExtension.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ extension.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "group")
+ {
+ level = 3;
+ XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h);
+ if(group != null)
+ extension.particle = group;
+ continue;
+ }
+ if(reader.LocalName == "all")
+ {
+ level = 3;
+ XmlSchemaAll all = XmlSchemaAll.Read(reader,h);
+ if(all != null)
+ extension.particle = all;
+ continue;
+ }
+ if(reader.LocalName == "choice")
+ {
+ level = 3;
+ XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h);
+ if(choice != null)
+ extension.particle = choice;
+ continue;
+ }
+ if(reader.LocalName == "sequence")
+ {
+ level = 3;
+ XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h);
+ if(sequence != null)
+ extension.particle = sequence;
+ continue;
+ }
+ }
+ if(level <= 3)
+ {
+ if(reader.LocalName == "attribute")
+ {
+ level = 3;
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ extension.Attributes.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ level = 3;
+ XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h);
+ if(attr != null)
+ extension.attributes.Add(attr);
+ continue;
+ }
+ }
+ if(level <= 4 && reader.LocalName == "anyAttribute")
+ {
+ level = 5;
+ XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h);
+ if(anyattr != null)
+ extension.AnyAttribute = anyattr;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return extension;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs
new file mode 100755
index 00000000000..e744a3a47c0
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs
@@ -0,0 +1,256 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaComplexContentRestriction.
+ /// </summary>
+ public class XmlSchemaComplexContentRestriction : XmlSchemaContent
+ {
+ private XmlSchemaAnyAttribute any;
+ private XmlSchemaObjectCollection attributes;
+ private XmlQualifiedName baseTypeName;
+ private XmlSchemaParticle particle;
+ private static string xmlname = "restriction";
+
+ public XmlSchemaComplexContentRestriction()
+ {
+ baseTypeName = XmlQualifiedName.Empty;
+ attributes = new XmlSchemaObjectCollection();
+ }
+
+ [System.Xml.Serialization.XmlAttribute("base")]
+ public XmlQualifiedName BaseTypeName
+ {
+ get{ return baseTypeName; }
+ set{ baseTypeName = value; }
+ }
+
+ [XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaParticle Particle
+ {
+ get{ return particle; }
+ set{ particle = value; }
+ }
+
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Attributes
+ {
+ get{ return attributes; }
+ }
+
+ [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnyAttribute AnyAttribute
+ {
+ get{ return any; }
+ set{ any = value; }
+ }
+
+ /// <remarks>
+ /// 1. base must be present
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(BaseTypeName == null || BaseTypeName.IsEmpty)
+ {
+ error(h, "base must be present and a QName");
+ }
+ else if(!XmlSchemaUtil.CheckQName(BaseTypeName))
+ error(h,"BaseTypeName is not a valid XmlQualifiedName");
+
+ if(this.AnyAttribute != null)
+ {
+ errorCount += AnyAttribute.Compile(h,info);
+ }
+
+ foreach(XmlSchemaObject obj in Attributes)
+ {
+ if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ errorCount += attr.Compile(h,info);
+ }
+ else if(obj is XmlSchemaAttributeGroupRef)
+ {
+ XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;
+ errorCount += atgrp.Compile(h,info);
+ }
+ else
+ error(h,obj.GetType() +" is not valid in this place::ComplexContentRestriction");
+ }
+
+ if(Particle != null)
+ {
+ if(Particle is XmlSchemaGroupRef)
+ {
+ errorCount += ((XmlSchemaGroupRef)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaAll)
+ {
+ errorCount += ((XmlSchemaAll)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaChoice)
+ {
+ errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaSequence)
+ {
+ errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);
+ }
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<restriction
+ // base = QName
+ // id = ID
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))
+ //</restriction>
+ internal static XmlSchemaComplexContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaComplexContentRestriction restriction = new XmlSchemaComplexContentRestriction();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexContentRestriction.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ restriction.LineNumber = reader.LineNumber;
+ restriction.LinePosition = reader.LinePosition;
+ restriction.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "base")
+ {
+ Exception innerex;
+ restriction.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for base attribute",innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ restriction.Id = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for restriction",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,restriction);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return restriction;
+ //Content: 1. annotation?,
+ // (2.(group | all | choice | sequence)?, (3.(attribute | attributeGroup)*, 4.anyAttribute?)))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaComplexContentRestriction.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ restriction.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "group")
+ {
+ level = 3;
+ XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h);
+ if(group != null)
+ restriction.particle = group;
+ continue;
+ }
+ if(reader.LocalName == "all")
+ {
+ level = 3;
+ XmlSchemaAll all = XmlSchemaAll.Read(reader,h);
+ if(all != null)
+ restriction.particle = all;
+ continue;
+ }
+ if(reader.LocalName == "choice")
+ {
+ level = 3;
+ XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h);
+ if(choice != null)
+ restriction.particle = choice;
+ continue;
+ }
+ if(reader.LocalName == "sequence")
+ {
+ level = 3;
+ XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h);
+ if(sequence != null)
+ restriction.particle = sequence;
+ continue;
+ }
+ }
+ if(level <= 3)
+ {
+ if(reader.LocalName == "attribute")
+ {
+ level = 3;
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ restriction.Attributes.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ level = 3;
+ XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h);
+ if(attr != null)
+ restriction.attributes.Add(attr);
+ continue;
+ }
+ }
+ if(level <= 4 && reader.LocalName == "anyAttribute")
+ {
+ level = 5;
+ XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h);
+ if(anyattr != null)
+ restriction.AnyAttribute = anyattr;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return restriction;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs
new file mode 100755
index 00000000000..113aff9f415
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs
@@ -0,0 +1,463 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.ComponentModel;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaComplexType.
+ /// </summary>
+ public class XmlSchemaComplexType : XmlSchemaType
+ {
+ private XmlSchemaAnyAttribute anyAttribute;
+ private XmlSchemaObjectCollection attributes;
+ private XmlSchemaObjectTable attributeUses;
+ private XmlSchemaAnyAttribute attributeWildcard;
+ private XmlSchemaDerivationMethod block;
+ private XmlSchemaDerivationMethod blockResolved;
+ private XmlSchemaContentModel contentModel;
+ private XmlSchemaContentType contentType;
+ private XmlSchemaParticle contentTypeParticle;
+ private bool isAbstract;
+ private bool isMixed;
+ private XmlSchemaParticle particle;
+
+ internal bool istoplevel = false;
+ private static string xmlname = "complexType";
+
+ public XmlSchemaComplexType()
+ {
+ attributes = new XmlSchemaObjectCollection();
+ block = XmlSchemaDerivationMethod.None;
+ attributeUses = new XmlSchemaObjectTable();
+ }
+
+ #region Attributes
+
+ [DefaultValue(false)]
+ [System.Xml.Serialization.XmlAttribute("abstract")]
+ public bool IsAbstract
+ {
+ get{ return isAbstract; }
+ set{ isAbstract = value; }
+ }
+ [DefaultValue(XmlSchemaDerivationMethod.None)]
+ [System.Xml.Serialization.XmlAttribute("block")]
+ public XmlSchemaDerivationMethod Block
+ {
+ get{ return block; }
+ set{ block = value; }
+ }
+ [DefaultValue(false)]
+ [System.Xml.Serialization.XmlAttribute("mixed")]
+ public override bool IsMixed
+ {
+ get{ return isMixed; }
+ set{ isMixed = value; }
+ }
+
+ #endregion
+
+ #region Elements
+
+ [XmlElement("simpleContent",typeof(XmlSchemaSimpleContent),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("complexContent",typeof(XmlSchemaComplexContent),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaContentModel ContentModel
+ {
+ get{ return contentModel; }
+ set{ contentModel = value; }
+ }
+
+ //LAMESPEC: The default value for particle in Schema is of Type EmptyParticle (internal?)
+ [XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaParticle Particle
+ {
+ get{ return particle; }
+ set{ particle = value; }
+ }
+
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Attributes
+ {
+ get{ return attributes; }
+ }
+
+ [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnyAttribute AnyAttribute
+ {
+ get{ return anyAttribute; }
+ set{ anyAttribute = value; }
+ }
+
+ #endregion
+
+ #region XmlIgnore
+ [XmlIgnore]
+ public XmlSchemaContentType ContentType
+ {
+ get{ return contentType; }
+ }
+ [XmlIgnore]
+ public XmlSchemaParticle ContentTypeParticle
+ {
+ get{ return contentTypeParticle; }
+ }
+ [XmlIgnore]
+ public XmlSchemaDerivationMethod BlockResolved
+ {
+ get{ return blockResolved; }
+ }
+ [XmlIgnore]
+ public XmlSchemaObjectTable AttributeUses
+ {
+ get{ return attributeUses; }
+ }
+ [XmlIgnore]
+ public XmlSchemaAnyAttribute AttributeWildcard
+ {
+ get{ return attributeWildcard; }
+ }
+ #endregion
+
+ /// <remarks>
+ /// 1. If ContentModel is present, neither particle nor Attributes nor AnyAttribute can be present.
+ /// 2. If particle is present,
+ /// a. For a topLevelComplexType
+ /// 1. name must be present and type NCName
+ /// 2. if block is #all, blockdefault is #all, else List of (extension | restriction)
+ /// 3. if final is #all, finaldefault is #all, else List of (extension | restriction)
+ /// b. For a local Complex type
+ /// 1. abstract must be false
+ /// 2. Name must be absent
+ /// 3. final must be absent
+ /// 4. block must be absent
+ ///
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(istoplevel)
+ {
+ if(this.Name == null || this.Name == string.Empty)
+ error(h,"name must be present in a top level complex type");
+ else if(!XmlSchemaUtil.CheckNCName(Name))
+ error(h,"name must be a NCName");
+ else
+ this.qName = new XmlQualifiedName(Name,info.TargetNamespace);
+
+ if(Block != XmlSchemaDerivationMethod.None)
+ {
+ if(Block == XmlSchemaDerivationMethod.All)
+ {
+ blockResolved = XmlSchemaDerivationMethod.All;
+ }
+ else
+ {
+ //TODO: Check what all is not allowed
+ blockResolved = Block & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);
+ }
+ }
+ else
+ {
+ if(info.BlockDefault == XmlSchemaDerivationMethod.All)
+ {
+ blockResolved = XmlSchemaDerivationMethod.All;
+ }
+ else
+ blockResolved = info.BlockDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);
+ }
+ if(Final != XmlSchemaDerivationMethod.None)
+ {
+ if(Final == XmlSchemaDerivationMethod.All)
+ {
+ finalResolved = XmlSchemaDerivationMethod.All;
+ }
+ else
+ {
+ //TODO: Check what all is not allowed
+ finalResolved = Final & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);
+ }
+ }
+ else
+ {
+ if(info.FinalDefault == XmlSchemaDerivationMethod.All)
+ {
+ finalResolved = XmlSchemaDerivationMethod.All;
+ }
+ else
+ {
+ finalResolved = info.BlockDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);
+ }
+ }
+ }
+ else // Not Top Level
+ {
+ if(isAbstract)
+ error(h,"abstract must be false in a local complex type");
+ if(Name != null)
+ error(h,"name must be absent in a local complex type");
+ if(Final != XmlSchemaDerivationMethod.None)
+ error(h,"final must be absent in a local complex type");
+ if(block != XmlSchemaDerivationMethod.None)
+ error(h,"block must be absent in a local complex type");
+ }
+
+ if(ContentModel != null)
+ {
+ if(anyAttribute != null || Attributes.Count != 0 || Particle != null)
+ error(h,"attributes, particles or anyattribute is not allowed if ContentModel is present");
+
+ if(ContentModel is XmlSchemaSimpleContent)
+ {
+ XmlSchemaSimpleContent smodel = (XmlSchemaSimpleContent)ContentModel;
+ errorCount += smodel.Compile(h,info);
+ }
+ else if(ContentModel is XmlSchemaComplexContent)
+ {
+ XmlSchemaComplexContent cmodel = (XmlSchemaComplexContent)ContentModel;
+ errorCount += cmodel.Compile(h,info);
+ }
+ }
+ else
+ {
+ if(Particle is XmlSchemaGroupRef)
+ {
+ XmlSchemaGroupRef xsgr = (XmlSchemaGroupRef)Particle;
+ errorCount += xsgr.Compile(h,info);
+ }
+ else if(Particle is XmlSchemaAll)
+ {
+ XmlSchemaAll xsa = (XmlSchemaAll)Particle;
+ errorCount += xsa.Compile(h,info);
+ }
+ else if(Particle is XmlSchemaChoice)
+ {
+ XmlSchemaChoice xsc = (XmlSchemaChoice)Particle;
+ errorCount += xsc.Compile(h,info);
+ }
+ else if(Particle is XmlSchemaSequence)
+ {
+ XmlSchemaSequence xss = (XmlSchemaSequence)Particle;
+ errorCount += xss.Compile(h,info);
+ }
+
+ if(this.anyAttribute != null)
+ {
+ AnyAttribute.Compile(h,info);
+ }
+ foreach(XmlSchemaObject obj in Attributes)
+ {
+ if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ errorCount += attr.Compile(h,info);
+ }
+ else if(obj is XmlSchemaAttributeGroupRef)
+ {
+ XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;
+ errorCount += atgrp.Compile(h,info);
+ }
+ else
+ error(h,obj.GetType() +" is not valid in this place::ComplexType");
+ }
+ }
+
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<complexType
+ // abstract = boolean : false
+ // block = (#all | List of (extension | restriction))
+ // final = (#all | List of (extension | restriction))
+ // id = ID
+ // mixed = boolean : false
+ // name = NCName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))))
+ //</complexType>
+ internal static XmlSchemaComplexType Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaComplexType ctype = new XmlSchemaComplexType();
+ reader.MoveToElement();
+ Exception innerex;
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexType.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ ctype.LineNumber = reader.LineNumber;
+ ctype.LinePosition = reader.LinePosition;
+ ctype.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "abstract")
+ {
+ ctype.IsAbstract = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h,reader.Value + " is invalid value for abstract",innerex);
+ }
+ else if(reader.Name == "block")
+ {
+ ctype.block = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "block");
+ if(innerex != null)
+ warn(h,"some invalid values for block attribute were found",innerex);
+ }
+ else if(reader.Name == "final")
+ {
+ ctype.Final = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "block");
+ if(innerex != null)
+ warn(h,"some invalid values for final attribute were found",innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ ctype.Id = reader.Value;
+ }
+ else if(reader.Name == "mixed")
+ {
+ ctype.isMixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h,reader.Value + " is invalid value for mixed",innerex);
+ }
+ else if(reader.Name == "name")
+ {
+ ctype.Name = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for complexType",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,ctype);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return ctype;
+
+ //Content: 1. annotation?,
+ // 2. simpleContent | 2. complexContent |
+ // (3.(group | all | choice | sequence)?, (4.(attribute | attributeGroup)*, 5.anyAttribute?)))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaComplexType.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ ctype.Annotation = annotation;
+ continue;
+ }
+ if(level <=2)
+ {
+ if(reader.LocalName == "simpleContent")
+ {
+ level = 6;
+ XmlSchemaSimpleContent simple = XmlSchemaSimpleContent.Read(reader,h);
+ if(simple != null)
+ ctype.ContentModel = simple;
+ continue;
+ }
+ if(reader.LocalName == "complexContent")
+ {
+ level = 6;
+ XmlSchemaComplexContent complex = XmlSchemaComplexContent.Read(reader,h);
+ if(complex != null)
+ ctype.contentModel = complex;
+ continue;
+ }
+ }
+ if(level <= 3)
+ {
+ if(reader.LocalName == "group")
+ {
+ level = 4;
+ XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h);
+ if(group != null)
+ ctype.particle = group;
+ continue;
+ }
+ if(reader.LocalName == "all")
+ {
+ level = 4;
+ XmlSchemaAll all = XmlSchemaAll.Read(reader,h);
+ if(all != null)
+ ctype.particle = all;
+ continue;
+ }
+ if(reader.LocalName == "choice")
+ {
+ level = 4;
+ XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h);
+ if(choice != null)
+ ctype.particle = choice;
+ continue;
+ }
+ if(reader.LocalName == "sequence")
+ {
+ level = 4;
+ XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h);
+ if(sequence != null)
+ ctype.particle = sequence;
+ continue;
+ }
+ }
+ if(level <= 4)
+ {
+ if(reader.LocalName == "attribute")
+ {
+ level = 4;
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ ctype.Attributes.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ level = 4;
+ XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h);
+ if(attr != null)
+ ctype.attributes.Add(attr);
+ continue;
+ }
+ }
+ if(level <= 5 && reader.LocalName == "anyAttribute")
+ {
+ level = 6;
+ XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h);
+ if(anyattr != null)
+ ctype.AnyAttribute = anyattr;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return ctype;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContent.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContent.cs
new file mode 100755
index 00000000000..ac32916437a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContent.cs
@@ -0,0 +1,15 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaContent.
+ /// </summary>
+ public abstract class XmlSchemaContent : XmlSchemaAnnotated
+ {
+ protected XmlSchemaContent()
+ {}
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentModel.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentModel.cs
new file mode 100755
index 00000000000..994dd211de5
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentModel.cs
@@ -0,0 +1,19 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaContentModel.
+ /// </summary>
+ public abstract class XmlSchemaContentModel : XmlSchemaAnnotated
+ {
+ protected XmlSchemaContentModel()
+ {
+ }
+ [XmlIgnore]
+ public abstract XmlSchemaContent Content {get; set;}
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentProcessing.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentProcessing.cs
new file mode 100755
index 00000000000..2cd60231a03
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentProcessing.cs
@@ -0,0 +1,22 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaContentProcessing.
+ /// </summary>
+ public enum XmlSchemaContentProcessing
+ {
+ [XmlIgnore]
+ None = 0,
+ [XmlEnum("skip")]
+ Skip = 1,
+ [XmlEnum("lax")]
+ Lax = 2,
+ [XmlEnum("strict")]
+ Strict = 3,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentType.cs
new file mode 100755
index 00000000000..dc7bda2433e
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentType.cs
@@ -0,0 +1,17 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaContentType.
+ /// </summary>
+ public enum XmlSchemaContentType
+ {
+ TextOnly = 0,
+ Empty = 1,
+ ElementOnly = 2,
+ Mixed = 3,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs
new file mode 100755
index 00000000000..778a9ef39ec
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs
@@ -0,0 +1,30 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaDatatype.
+ /// </summary>
+ public abstract class XmlSchemaDatatype
+ {
+ protected XmlSchemaDatatype()
+ {
+ }
+
+ public abstract XmlTokenizedType TokenizedType { get; }
+ public abstract Type ValueType { get; }
+
+ // Methods
+ public abstract object ParseValue(string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr);
+
+ //TODO: This should return appropriate inbuilt type
+ internal static XmlSchemaDatatype GetType(XmlQualifiedName qname)
+ {
+ return null;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDerivationMethod.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDerivationMethod.cs
new file mode 100755
index 00000000000..fcd63c899fe
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDerivationMethod.cs
@@ -0,0 +1,31 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaDerivationMethod.
+ /// </summary>
+ [Flags]
+ public enum XmlSchemaDerivationMethod
+ {
+ [XmlEnum("")]
+ Empty = 0x00000000,
+ [XmlEnum("substitution")]
+ Substitution= 0x00000001,
+ [XmlEnum("extension")]
+ Extension = 0x00000002,
+ [XmlEnum("restriction")]
+ Restriction = 0x00000004,
+ [XmlEnum("list")]
+ List = 0x00000008,
+ [XmlEnum("union")]
+ Union = 0x00000010,
+ [XmlEnum("#all")]
+ All = 0x000000FF,
+ [XmlIgnore]
+ None = 0x00000100,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDocumentation.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDocumentation.cs
new file mode 100755
index 00000000000..7788d6d685b
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDocumentation.cs
@@ -0,0 +1,104 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaDocumentation.
+ /// </summary>
+ public class XmlSchemaDocumentation : XmlSchemaObject
+ {
+ private string language;
+ private XmlNode[] markup;
+ private string source;
+
+ public XmlSchemaDocumentation()
+ {
+ }
+
+ [XmlAnyElement]
+ [XmlText]
+ public XmlNode[] Markup
+ {
+ get{ return markup; }
+ set{ markup = value; }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("source")]
+ public string Source
+ {
+ get{ return source; }
+ set{ source = value; }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("xml:lang")]
+ public string Language
+ {
+ get{ return language; }
+ set{ language = value; }
+ }
+
+ //<documentation
+ // source = anyURI
+ // xml:lang = language>
+ // Content: ({any})*
+ //</documentation>
+ internal static XmlSchemaDocumentation Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip)
+ {
+ skip = false;
+ XmlSchemaDocumentation doc = new XmlSchemaDocumentation();
+
+ reader.MoveToElement();
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "documentation")
+ {
+ error(h,"Should not happen :1: XmlSchemaDocumentation.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ doc.LineNumber = reader.LineNumber;
+ doc.LinePosition = reader.LinePosition;
+ doc.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "source")
+ {
+ doc.source = reader.Value;
+ }
+ else if(reader.Name == "xml:lang")
+ {
+ doc.language = reader.Value;
+ }
+ else
+ {
+ error(h,reader.Name + " is not a valid attribute for documentation",null);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return doc;
+
+ //Content {any}*
+ XmlDocument xmldoc = new XmlDocument();
+ xmldoc.AppendChild(xmldoc.ReadNode(reader));
+ XmlNode root = xmldoc.FirstChild;
+ if(root != null && root.ChildNodes != null)
+ {
+ doc.Markup = new XmlNode[root.ChildNodes.Count];
+ for(int i=0;i<root.ChildNodes.Count;i++)
+ {
+ doc.Markup[i] = root.ChildNodes[i];
+ }
+ }
+ if(reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement)
+ skip = true;
+
+ return doc;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs
new file mode 100755
index 00000000000..5f95fd66ef2
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs
@@ -0,0 +1,625 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+using System.ComponentModel;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaElement.
+ /// </summary>
+ public class XmlSchemaElement : XmlSchemaParticle
+ {
+ private XmlSchemaDerivationMethod block;
+ private XmlSchemaDerivationMethod blockResolved;
+ private XmlSchemaObjectCollection constraints;
+ private string defaultValue;
+ private object elementType;
+ private XmlSchemaDerivationMethod final;
+ private XmlSchemaDerivationMethod finalResolved;
+ private string fixedValue;
+ private XmlSchemaForm form;
+ private bool isAbstract;
+ private bool isNillable;
+ private string name;
+ private XmlQualifiedName qName;
+ private XmlQualifiedName refName;
+ private XmlSchemaType schemaType;
+ private XmlQualifiedName schemaTypeName;
+ private XmlQualifiedName substitutionGroup;
+ internal bool parentIsSchema = false;
+ private string targetNamespace;
+ private string hash;
+
+ private static string xmlname = "element";
+
+ public XmlSchemaElement()
+ {
+ block = XmlSchemaDerivationMethod.None;
+ final = XmlSchemaDerivationMethod.None;
+ constraints = new XmlSchemaObjectCollection();
+ qName = XmlQualifiedName.Empty;
+ refName = XmlQualifiedName.Empty;
+ schemaTypeName = XmlQualifiedName.Empty;
+ substitutionGroup = XmlQualifiedName.Empty;
+ substitutionGroup = XmlQualifiedName.Empty;
+ }
+
+ #region Attributes
+
+ [DefaultValue(false)]
+ [System.Xml.Serialization.XmlAttribute("abstract")]
+ public bool IsAbstract
+ {
+ get{ return isAbstract; }
+ set{ isAbstract = value; }
+ }
+
+ [DefaultValue(XmlSchemaDerivationMethod.None)]
+ [System.Xml.Serialization.XmlAttribute("block")]
+ public XmlSchemaDerivationMethod Block
+ {
+ get{ return block; }
+ set{ block = value; }
+ }
+
+ [DefaultValue(null)]
+ [System.Xml.Serialization.XmlAttribute("default")]
+ public string DefaultValue
+ {
+ get{ return defaultValue; }
+ set{ defaultValue = value; }
+ }
+
+ [DefaultValue(XmlSchemaDerivationMethod.None)]
+ [System.Xml.Serialization.XmlAttribute("final")]
+ public XmlSchemaDerivationMethod Final
+ {
+ get{ return final; }
+ set{ final = value; }
+ }
+
+ [DefaultValue(null)]
+ [System.Xml.Serialization.XmlAttribute("fixed")]
+ public string FixedValue
+ {
+ get{ return fixedValue; }
+ set{ fixedValue = value; }
+ }
+ [DefaultValue(XmlSchemaForm.None)]
+ [System.Xml.Serialization.XmlAttribute("form")]
+ public XmlSchemaForm Form
+ {
+ get{ return form; }
+ set{ form = value; }
+ }
+
+ [DefaultValue(null)]
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name; }
+ set{ name = value; }
+ }
+
+ [DefaultValue(false)]
+ [System.Xml.Serialization.XmlAttribute("nillable")]
+ public bool IsNillable
+ {
+ get{ return isNillable; }
+ set{ isNillable = value; }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("ref")]
+ public XmlQualifiedName RefName
+ {
+ get{ return refName; }
+ set{ refName = value;}
+ }
+
+ [System.Xml.Serialization.XmlAttribute("substitutionGroup")]
+ public XmlQualifiedName SubstitutionGroup
+ {
+ get{ return substitutionGroup; }
+ set{ substitutionGroup = value; }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("type")]
+ public XmlQualifiedName SchemaTypeName
+ {
+ get{ return schemaTypeName; }
+ set{ schemaTypeName = value; }
+ }
+
+ [XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("complexType",typeof(XmlSchemaComplexType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaType SchemaType
+ {
+ get{ return schemaType; }
+ set{ schemaType = value; }
+ }
+
+ [XmlElement("unique",typeof(XmlSchemaUnique),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("key",typeof(XmlSchemaKey),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("keyref",typeof(XmlSchemaKeyref),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Constraints
+ {
+ get{ return constraints; }
+ }
+
+ [XmlIgnore]
+ public XmlQualifiedName QualifiedName
+ {
+ get{ return qName; }
+ }
+
+ [XmlIgnore]
+ public object ElementType
+ {
+ get{ return elementType; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaDerivationMethod BlockResolved
+ {
+ get{ return blockResolved; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaDerivationMethod FinalResolved
+ {
+ get{ return finalResolved; }
+ }
+
+ #endregion
+
+ /// <remarks>
+ /// a) If Element has parent as schema:
+ /// 1. name must be present and of type NCName.
+ /// 2. ref must be absent
+ /// 3. form must be absent
+ /// 4. minOccurs must be absent
+ /// 5. maxOccurs must be absent
+ /// b) If Element has parent is not schema and ref is absent
+ /// 1. name must be present and of type NCName.
+ /// 2. if form equals qualified or form is absent and schema's formdefault is qualifed,
+ /// targetNamespace is schema's targetnamespace else empty.
+ /// 3. type and either <simpleType> or <complexType> are mutually exclusive
+ /// 4. default and fixed must not both be present.
+ /// 5. substitutiongroup must be absent
+ /// 6. final must be absent
+ /// 7. abstract must be absent
+ /// c) if the parent is not schema and ref is set
+ /// 1. name must not be present
+ /// 2. all of <simpleType>,<complexType>, <key>, <keyref>, <unique>, nillable,
+ /// default, fixed, form, block and type, must be absent.
+ /// 3. substitutiongroup is prohibited
+ /// 4. final is prohibited
+ /// 5. abstract is prohibited
+ /// 6. default and fixed must not both be present.(Actually both are absent)
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(this.defaultValue != null && this.fixedValue != null)
+ error(h,"both default and fixed can't be present");
+
+ if(parentIsSchema)
+ {
+ if(this.refName != null && !RefName.IsEmpty)
+ error(h,"ref must be absent");
+
+ if(this.name == null) //b1
+ error(h,"Required attribute name must be present");
+ else if(!XmlSchemaUtil.CheckNCName(this.name)) // b1.2
+ error(h,"attribute name must be NCName");
+ else
+ this.qName = new XmlQualifiedName(this.name, info.TargetNamespace);
+
+ if(form != XmlSchemaForm.None)
+ error(h,"form must be absent");
+ if(MinOccursString != null)
+ error(h,"minOccurs must be absent");
+ if(MaxOccursString != null)
+ error(h,"maxOccurs must be absent");
+
+ XmlSchemaDerivationMethod allfinal = (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);
+ if(final == XmlSchemaDerivationMethod.All)
+ finalResolved = allfinal;
+ else if(final == XmlSchemaDerivationMethod.None)
+ finalResolved = info.BlockDefault & allfinal;
+ else
+ {
+ if((final & ~allfinal) != 0)
+ warn(h,"some values for final are invalid in this context");
+ finalResolved = final & allfinal;
+ }
+
+ XmlSchemaDerivationMethod allblock = XmlSchemaDerivationMethod.Extension |
+ XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution;
+
+ if(block == XmlSchemaDerivationMethod.All)
+ blockResolved = allblock;
+ else if(block == XmlSchemaDerivationMethod.None)
+ blockResolved = info.BlockDefault & allblock;
+ else
+ {
+ if((block & ~allblock) != 0)
+ warn(h,"Some of the values for block are invalid in this context");
+ blockResolved = block & allblock;
+ }
+
+ if(schemaType != null && schemaTypeName != null && !schemaTypeName.IsEmpty)
+ {
+ error(h,"both schemaType and content can't be present");
+ }
+
+ //Even if both are present, read both of them.
+ if(schemaType != null)
+ {
+ if(schemaType is XmlSchemaSimpleType)
+ {
+ errorCount += ((XmlSchemaSimpleType)schemaType).Compile(h,info);
+ }
+ else if(schemaType is XmlSchemaComplexType)
+ {
+ errorCount += ((XmlSchemaComplexType)schemaType).Compile(h,info);
+ }
+ else
+ error(h,"only simpletype or complextype is allowed");
+ }
+ if(schemaTypeName != null && !schemaTypeName.IsEmpty)
+ {
+ if(!XmlSchemaUtil.CheckQName(SchemaTypeName))
+ error(h,"SchemaTypeName must be an XmlQualifiedName");
+ }
+ if(SubstitutionGroup != null && !SubstitutionGroup.IsEmpty)
+ {
+ if(!XmlSchemaUtil.CheckQName(SubstitutionGroup))
+ error(h,"SubstitutionGroup must be a valid XmlQualifiedName");
+ }
+
+ foreach(XmlSchemaObject obj in constraints)
+ {
+ if(obj is XmlSchemaUnique)
+ errorCount += ((XmlSchemaUnique)obj).Compile(h,info);
+ else if(obj is XmlSchemaKey)
+ errorCount += ((XmlSchemaKey)obj).Compile(h,info);
+ else if(obj is XmlSchemaKeyref)
+ errorCount += ((XmlSchemaKeyref)obj).Compile(h,info);
+ }
+
+
+ }
+ else
+ {
+ if(substitutionGroup != null && !substitutionGroup.IsEmpty)
+ error(h,"substitutionGroup must be absent");
+ if(final != XmlSchemaDerivationMethod.None)
+ error(h,"final must be absent");
+ if(isAbstract)
+ error(h,"abstract must be absent");
+
+ //FIXME: Should we reset the values
+ if(MinOccurs > MaxOccurs)
+ error(h,"minOccurs must be less than or equal to maxOccurs");
+
+ if(refName == null || RefName.IsEmpty)
+ {
+ if(form == XmlSchemaForm.Qualified || (form == XmlSchemaForm.None && info.ElementFormDefault == XmlSchemaForm.Qualified))
+ this.targetNamespace = info.TargetNamespace;
+ else
+ this.targetNamespace = string.Empty;
+
+ if(this.name == null) //b1
+ error(h,"Required attribute name must be present");
+ else if(!XmlSchemaUtil.CheckNCName(this.name)) // b1.2
+ error(h,"attribute name must be NCName");
+ else
+ this.qName = new XmlQualifiedName(this.name, this.targetNamespace);
+
+ XmlSchemaDerivationMethod allblock = XmlSchemaDerivationMethod.Extension |
+ XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution;
+
+ if(block == XmlSchemaDerivationMethod.All)
+ blockResolved = allblock;
+ else if(block == XmlSchemaDerivationMethod.None)
+ blockResolved = info.BlockDefault & allblock;
+ else
+ {
+ if((block & ~allblock) != 0)
+ warn(h,"Some of the values for block are invalid in this context");
+ blockResolved = block & allblock;
+ }
+
+ if(schemaType != null && schemaTypeName != null && !schemaTypeName.IsEmpty)
+ {
+ error(h,"both schemaType and content can't be present");
+ }
+
+ //Even if both are present, read both of them.
+ if(schemaType != null)
+ {
+ if(schemaType is XmlSchemaSimpleType)
+ {
+ errorCount += ((XmlSchemaSimpleType)schemaType).Compile(h,info);
+ }
+ else if(schemaType is XmlSchemaComplexType)
+ {
+ errorCount += ((XmlSchemaComplexType)schemaType).Compile(h,info);
+ }
+ else
+ error(h,"only simpletype or complextype is allowed");
+ }
+ if(schemaTypeName != null && !schemaTypeName.IsEmpty)
+ {
+ if(!XmlSchemaUtil.CheckQName(SchemaTypeName))
+ error(h,"SchemaTypeName must be an XmlQualifiedName");
+ }
+ if(SubstitutionGroup != null && !SubstitutionGroup.IsEmpty)
+ {
+ if(!XmlSchemaUtil.CheckQName(SubstitutionGroup))
+ error(h,"SubstitutionGroup must be a valid XmlQualifiedName");
+ }
+
+ foreach(XmlSchemaObject obj in constraints)
+ {
+ if(obj is XmlSchemaUnique)
+ errorCount += ((XmlSchemaUnique)obj).Compile(h,info);
+ else if(obj is XmlSchemaKey)
+ errorCount += ((XmlSchemaKey)obj).Compile(h,info);
+ else if(obj is XmlSchemaKeyref)
+ errorCount += ((XmlSchemaKeyref)obj).Compile(h,info);
+ }
+ }
+ else
+ {
+ if(!XmlSchemaUtil.CheckQName(RefName))
+ error(h,"RefName must be a XmlQualifiedName");
+
+ if(name != null)
+ error(h,"name must not be present when ref is present");
+ if(Constraints.Count != 0)
+ error(h,"key, keyref and unique must be absent");
+ if(isNillable)
+ error(h,"nillable must be absent");
+ if(defaultValue != null)
+ error(h,"default must be absent");
+ if(fixedValue != null)
+ error(h,"fixed must be null");
+ if(form != XmlSchemaForm.None)
+ error(h,"form must be absent");
+ if(block != XmlSchemaDerivationMethod.None)
+ error(h,"block must be absent");
+ if(schemaTypeName != null && !schemaTypeName.IsEmpty)
+ error(h,"type must be absent");
+ if(SchemaType != null)
+ error(h,"simpleType or complexType must be absent");
+ }
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<element
+ // abstract = boolean : false
+ // block = (#all | List of (extension | restriction | substitution))
+ // default = string
+ // final = (#all | List of (extension | restriction))
+ // fixed = string
+ // form = (qualified | unqualified)
+ // id = ID
+ // maxOccurs = (nonNegativeInteger | unbounded) : 1
+ // minOccurs = nonNegativeInteger : 1
+ // name = NCName
+ // nillable = boolean : false
+ // ref = QName
+ // substitutionGroup = QName
+ // type = QName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*))
+ //</element>
+
+ internal static XmlSchemaElement Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaElement element = new XmlSchemaElement();
+ Exception innerex;
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaElement.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ element.LineNumber = reader.LineNumber;
+ element.LinePosition = reader.LinePosition;
+ element.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "abstract")
+ {
+ element.IsAbstract = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h,reader.Value + " is invalid value for abstract",innerex);
+ }
+ else if(reader.Name == "block")
+ {
+ element.block = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "block");
+ if(innerex != null)
+ warn(h,"some invalid values for block attribute were found",innerex);
+ }
+ else if(reader.Name == "default")
+ {
+ element.defaultValue = reader.Value;
+ }
+ else if(reader.Name == "final")
+ {
+ element.Final = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "block");
+ if(innerex != null)
+ warn(h,"some invalid values for final attribute were found",innerex);
+ }
+ else if(reader.Name == "fixed")
+ {
+ element.fixedValue = reader.Value;
+ }
+ else if(reader.Name == "form")
+ {
+ element.form = XmlSchemaUtil.ReadFormAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h,reader.Value + " is an invalid value for form attribute",innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ element.Id = reader.Value;
+ }
+ else if(reader.Name == "maxOccurs")
+ {
+ try
+ {
+ element.MaxOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for maxOccurs",e);
+ }
+ }
+ else if(reader.Name == "minOccurs")
+ {
+ try
+ {
+ element.MinOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for minOccurs",e);
+ }
+ }
+ else if(reader.Name == "name")
+ {
+ element.Name = reader.Value;
+ }
+ else if(reader.Name == "nillable")
+ {
+ element.IsNillable = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h,reader.Value + "is not a valid value for nillable",innerex);
+ }
+ else if(reader.Name == "ref")
+ {
+ element.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for ref attribute",innerex);
+ }
+ else if(reader.Name == "substitutionGroup")
+ {
+ element.substitutionGroup = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for substitutionGroup attribute",innerex);
+ }
+ else if(reader.Name == "type")
+ {
+ element.SchemaTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for type attribute",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for element",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,element);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return element;
+
+ // Content: annotation?,
+ // (simpleType | complexType)?,
+ // (unique | key | keyref)*
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaElement.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ element.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "simpleType")
+ {
+ level = 3;
+ XmlSchemaSimpleType simple = XmlSchemaSimpleType.Read(reader,h);
+ if(simple != null)
+ element.SchemaType = simple;
+ continue;
+ }
+ if(reader.LocalName == "complexType")
+ {
+ level = 3;
+ XmlSchemaComplexType complex = XmlSchemaComplexType.Read(reader,h);
+ if(complex != null)
+ {
+ element.SchemaType = complex;
+ }
+ continue;
+ }
+ }
+ if(level <= 3)
+ {
+ if(reader.LocalName == "unique")
+ {
+ level = 3;
+ XmlSchemaUnique unique = XmlSchemaUnique.Read(reader,h);
+ if(unique != null)
+ element.constraints.Add(unique);
+ continue;
+ }
+ else if(reader.LocalName == "key")
+ {
+ level = 3;
+ XmlSchemaKey key = XmlSchemaKey.Read(reader,h);
+ if(key != null)
+ element.constraints.Add(key);
+ continue;
+ }
+ else if(reader.LocalName == "keyref")
+ {
+ level = 3;
+ XmlSchemaKeyref keyref = XmlSchemaKeyref.Read(reader,h);
+ if(keyref != null)
+ element.constraints.Add(keyref);
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return element;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaEnumerationFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaEnumerationFacet.cs
new file mode 100755
index 00000000000..512b3c7d70a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaEnumerationFacet.cs
@@ -0,0 +1,87 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaEnumerationFacet.
+ /// </summary>
+ public class XmlSchemaEnumerationFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "enumeration";
+ public XmlSchemaEnumerationFacet()
+ {
+ }
+
+ //<enumeration
+ // id = ID
+ // value = anySimpleType
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</enumeration>
+ internal static XmlSchemaEnumerationFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaEnumerationFacet enumeration = new XmlSchemaEnumerationFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaEnumerationFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ enumeration.LineNumber = reader.LineNumber;
+ enumeration.LinePosition = reader.LinePosition;
+ enumeration.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ enumeration.Id = reader.Value;
+ }
+ else if(reader.Name == "value")
+ {
+ enumeration.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,enumeration);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return enumeration;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaEnumerationFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ enumeration.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return enumeration;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaException.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaException.cs
new file mode 100755
index 00000000000..01ea8721d3b
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaException.cs
@@ -0,0 +1,94 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Runtime.Serialization;
+
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaException.
+ /// </summary>
+ [Serializable]
+ public class XmlSchemaException : System.SystemException
+ {
+ //fields
+ private int lineNumber;
+ private int linePosition;
+ private XmlSchemaObject sourceObj;
+ private string sourceUri;
+
+ protected XmlSchemaException(SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ this.lineNumber = info.GetInt32 ("lineNumber");
+ this.linePosition = info.GetInt32 ("linePosition");
+ this.sourceUri = info.GetString ("sourceUri");
+ this.sourceObj = info.GetValue ("sourceObj", typeof (XmlSchemaObject)) as XmlSchemaObject;
+ }
+
+
+ internal XmlSchemaException(string message, int lineNumber, int linePosition,
+ XmlSchemaObject sourceObject, string sourceUri, Exception innerException)
+ : base(message, innerException)
+ {
+ this.lineNumber = lineNumber;
+ this.linePosition = linePosition;
+ this.sourceObj = sourceObject;
+ this.sourceUri = sourceUri;
+ }
+ internal XmlSchemaException(string message, XmlSchemaObject sourceObject,
+ Exception innerException)
+ : base(message, innerException)
+ {
+ this.lineNumber = sourceObject.LineNumber;
+ this.linePosition = sourceObject.LinePosition;
+ this.sourceObj = sourceObject;
+ this.sourceUri = sourceObject.SourceUri;
+ }
+
+ public XmlSchemaException(string message, Exception innerException)
+ : base(message,innerException){}
+
+ // Properties
+ public int LineNumber
+ {
+ get{ return this.lineNumber;}
+ }
+ public int LinePosition
+ {
+ get{ return this.linePosition;}
+ }
+ public XmlSchemaObject SourceSchemaObject
+ {
+ get{ return this.sourceObj; }
+ }
+ public string SourceUri
+ {
+ get{ return this.sourceUri; }
+ }
+
+ public override string Message
+ {
+ get {
+ string msg = base.Message;
+ if (sourceUri != null)
+ msg = String.Format ("XmlSchema error: {0}\n" +
+ "URI: {1}, line {2}, position {3}",
+ msg, sourceUri, lineNumber, linePosition);
+
+ return msg;
+ }
+ }
+
+ // Methods
+ public override void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ base.GetObjectData (info, context);
+ info.AddValue ("lineNumber", lineNumber);
+ info.AddValue ("linePosition", linePosition);
+ info.AddValue ("sourceUri", sourceUri);
+ info.AddValue ("sourceObj", sourceObj);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaExternal.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaExternal.cs
new file mode 100755
index 00000000000..1f691587ea1
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaExternal.cs
@@ -0,0 +1,62 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+using System.Collections;
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaExternal.
+ /// </summary>
+ public abstract class XmlSchemaExternal : XmlSchemaObject
+ {
+ private string id;
+ private XmlSchema schema;
+ private string location;
+ private XmlAttribute[] unhandledAttributes;
+
+ protected XmlSchemaExternal()
+ {}
+
+ [System.Xml.Serialization.XmlAttribute("schemaLocation")]
+ public string SchemaLocation
+ {
+ get{ return location; }
+ set{ location = value; }
+ }
+
+ [XmlIgnore]
+ public XmlSchema Schema
+ {
+ get{ return schema; }
+ set{ schema = value; }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("id")]
+ public string Id
+ {
+ get{ return id; }
+ set{ id = value; }
+ }
+
+ [XmlAnyAttribute]
+ public XmlAttribute[] UnhandledAttributes
+ {
+ get
+ {
+ if(unhandledAttributeList != null)
+ {
+ unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
+ unhandledAttributeList = null;
+ }
+ return unhandledAttributes;
+ }
+ set
+ {
+ unhandledAttributes = value;
+ unhandledAttributeList = null;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaFacet.cs
new file mode 100755
index 00000000000..076bc74486d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaFacet.cs
@@ -0,0 +1,37 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+using System.ComponentModel;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaFacet.
+ /// </summary>
+ public abstract class XmlSchemaFacet : XmlSchemaAnnotated
+ {
+ private bool isFixed;
+ private string val;
+
+ protected XmlSchemaFacet()
+ {
+ }
+
+ [System.Xml.Serialization.XmlAttribute("value")]
+ public string Value
+ {
+ get{ return val; }
+ set{ val = value; }
+ }
+
+ [DefaultValue(false)]
+ [System.Xml.Serialization.XmlAttribute("fixed")]
+ public virtual bool IsFixed
+ {
+ get{ return isFixed; }
+ set{ isFixed = value; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaForm.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaForm.cs
new file mode 100755
index 00000000000..8efb7e3d548
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaForm.cs
@@ -0,0 +1,19 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaForm.
+ /// </summary>
+ public enum XmlSchemaForm
+ {
+ [XmlIgnore]
+ None = 0x00000000,
+ [XmlEnum("qualified")]
+ Qualified = 0x00000001,
+ [XmlEnum("unqualified")]
+ Unqualified = 0x00000002,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaFractionDigitsFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaFractionDigitsFacet.cs
new file mode 100755
index 00000000000..319d19fd8e3
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaFractionDigitsFacet.cs
@@ -0,0 +1,98 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaFractionDigitsFacet.
+ /// </summary>
+ public class XmlSchemaFractionDigitsFacet : XmlSchemaNumericFacet
+ {
+ private static string xmlname = "fractionDigits";
+
+ public XmlSchemaFractionDigitsFacet()
+ {
+ }
+
+ //<fractionDigits
+ // fixed = boolean : false
+ // id = ID
+ // value = nonNegativeInteger
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</fractionDigits>
+ internal static XmlSchemaFractionDigitsFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaFractionDigitsFacet fraction = new XmlSchemaFractionDigitsFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaFractionDigitsFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ fraction.LineNumber = reader.LineNumber;
+ fraction.LinePosition = reader.LinePosition;
+ fraction.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ fraction.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ fraction.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ fraction.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,fraction);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return fraction;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaFractionDigitsFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ fraction.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return fraction;
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroup.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroup.cs
new file mode 100755
index 00000000000..9848d6ad319
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroup.cs
@@ -0,0 +1,195 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// refers to the named group
+ /// </summary>
+ public class XmlSchemaGroup : XmlSchemaAnnotated
+ {
+ private string name;
+ private XmlSchemaGroupBase particle;
+ private XmlQualifiedName qualifiedName;
+
+ private static string xmlname = "group";
+
+ public XmlSchemaGroup()
+ {
+ }
+
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name; }
+ set{ name = value; }
+ }
+
+ [XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaGroupBase Particle
+ {
+ get{ return particle; }
+ set{ particle = value; }
+ }
+
+ [XmlIgnore]
+ internal XmlQualifiedName QualifiedName
+ {
+ get{ return qualifiedName;}
+ }
+
+ // 1. name must be present
+ // 2. MinOccurs & MaxOccurs of the Particle must be absent
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(Name == null)
+ error(h,"Required attribute name must be present");
+ else if(!XmlSchemaUtil.CheckNCName(this.name))
+ error(h,"attribute name must be NCName");
+ else
+ qualifiedName = new XmlQualifiedName(Name,info.TargetNamespace);
+
+ if(Particle == null)
+ {
+ error(h,"Particle is required");
+ }
+ else
+ {
+ if(Particle.MaxOccursString != null)
+ Particle.error(h,"MaxOccurs must not be present when the Particle is a child of Group");
+ if(Particle.MinOccursString != null)
+ Particle.error(h,"MinOccurs must not be present when the Particle is a child of Group");
+
+ if(Particle is XmlSchemaChoice)
+ {
+ errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaSequence)
+ {
+ errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaAll)
+ {
+ errorCount += ((XmlSchemaAll)Particle).Compile(h,info);
+ }
+ else
+ {
+ error(h,"only all,choice or sequence are allowed");
+ }
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //From the Errata
+ //<group
+ // id = ID
+ // name = NCName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (all | choice | sequence)?)
+ //</group>
+ internal static XmlSchemaGroup Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaGroup group = new XmlSchemaGroup();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaGroup.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ group.LineNumber = reader.LineNumber;
+ group.LinePosition = reader.LinePosition;
+ group.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ group.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ group.name = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for group",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,group);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return group;
+
+// Content: (annotation?, (all | choice | sequence)?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaGroup.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ group.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "all")
+ {
+ level = 3;
+ XmlSchemaAll all = XmlSchemaAll.Read(reader,h);
+ if(all != null)
+ group.Particle = all;
+ continue;
+ }
+ if(reader.LocalName == "choice")
+ {
+ level = 3;
+ XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h);
+ if(choice != null)
+ group.Particle = choice;
+ continue;
+ }
+ if(reader.LocalName == "sequence")
+ {
+ level = 3;
+ XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h);
+ if(sequence != null)
+ group.Particle = sequence;
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return group;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupBase.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupBase.cs
new file mode 100755
index 00000000000..152e3b09f57
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupBase.cs
@@ -0,0 +1,20 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaGroupBase.
+ /// </summary>
+ public abstract class XmlSchemaGroupBase : XmlSchemaParticle
+ {
+ protected XmlSchemaGroupBase()
+ {
+ }
+
+ [XmlIgnore]
+ public abstract XmlSchemaObjectCollection Items { get; }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs
new file mode 100755
index 00000000000..31ceaf8e864
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs
@@ -0,0 +1,156 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaGroupRef.
+ /// </summary>
+ public class XmlSchemaGroupRef : XmlSchemaParticle
+ {
+ private XmlSchemaGroupBase particle;
+ private XmlQualifiedName refName;
+ private static string xmlname = "group";
+
+ public XmlSchemaGroupRef()
+ {
+ refName = XmlQualifiedName.Empty;
+ }
+ [System.Xml.Serialization.XmlAttribute("ref")]
+ public XmlQualifiedName RefName
+ {
+ get{ return refName; }
+ set{ refName = value; }
+ }
+ [XmlIgnore]
+ public XmlSchemaGroupBase Particle
+ {
+ get{ return particle; }
+ }
+ /// <remarks>
+ /// 1. RefName must be present
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ //FIXME: Should we reset the values
+ if(MinOccurs > MaxOccurs)
+ error(h,"minOccurs must be less than or equal to maxOccurs");
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ if(refName == null || refName.IsEmpty)
+ {
+ error(h,"ref must be present");
+ }
+ else if(!XmlSchemaUtil.CheckQName(RefName))
+ error(h, "RefName must be a valid XmlQualifiedName");
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ // <group
+ // id = ID
+ // ref = QName
+ // minOccurs = ? : 1
+ // maxOccurs = ? : 1>
+ // Content: (annotation?)
+ // </group>
+ internal static XmlSchemaGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaGroupRef groupref = new XmlSchemaGroupRef();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaGroup.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ groupref.LineNumber = reader.LineNumber;
+ groupref.LinePosition = reader.LinePosition;
+ groupref.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ groupref.Id = reader.Value;
+ }
+ else if(reader.Name == "ref")
+ {
+ Exception innerex;
+ groupref.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for ref attribute",innerex);
+ }
+ else if(reader.Name == "maxOccurs")
+ {
+ try
+ {
+ groupref.MaxOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for maxOccurs",e);
+ }
+ }
+ else if(reader.Name == "minOccurs")
+ {
+ try
+ {
+ groupref.MinOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for minOccurs", e);
+ }
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for group",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,groupref);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return groupref;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaGroupRef.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ groupref.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return groupref;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaIdentityConstraint.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaIdentityConstraint.cs
new file mode 100755
index 00000000000..7e09ca0842d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaIdentityConstraint.cs
@@ -0,0 +1,91 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaIdentityConstraint.
+ /// </summary>
+ public class XmlSchemaIdentityConstraint : XmlSchemaAnnotated
+ {
+ private XmlSchemaObjectCollection fields;
+ private string name;
+ private XmlQualifiedName qName;
+ private XmlSchemaXPath selector;
+
+ public XmlSchemaIdentityConstraint()
+ {
+ fields = new XmlSchemaObjectCollection();
+ qName = XmlQualifiedName.Empty;
+ }
+
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name; }
+ set{ name = value; }
+ }
+
+ [XmlElement("selector",typeof(XmlSchemaXPath),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaXPath Selector
+ {
+ get{ return selector; }
+ set{ selector = value; }
+ }
+
+ [XmlElement("field",typeof(XmlSchemaXPath),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Fields
+ {
+ get{ return fields; }
+ }
+
+ [XmlIgnore]
+ public XmlQualifiedName QualifiedName
+ {
+ get{ return qName; }
+ }
+ /// <remarks>
+ /// 1. name must be present
+ /// 2. selector and field must be present
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(Name == null)
+ error(h,"Required attribute name must be present");
+ else if(!XmlSchemaUtil.CheckNCName(this.name))
+ error(h,"attribute name must be NCName");
+ else
+ this.qName = new XmlQualifiedName(Name,info.TargetNamespace);
+
+ if(Selector == null)
+ error(h,"selector must be present");
+ else
+ {
+ errorCount += Selector.Compile(h,info);
+ }
+
+ if(Fields.Count == 0)
+ error(h,"atleast one field value must be present");
+ else
+ {
+ foreach(XmlSchemaObject obj in Fields)
+ {
+ if(obj is XmlSchemaXPath)
+ {
+ XmlSchemaXPath field = (XmlSchemaXPath)obj;
+ errorCount += field.Compile(h,info);
+ }
+ else
+ error(h,"Object of type "+obj.GetType()+" is invalid in the Fields Collection");
+ }
+ }
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaImport.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaImport.cs
new file mode 100755
index 00000000000..7586b2db155
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaImport.cs
@@ -0,0 +1,109 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaImport.
+ /// </summary>
+ public class XmlSchemaImport : XmlSchemaExternal
+ {
+ private XmlSchemaAnnotation annotation;
+ private string nameSpace;
+ private static string xmlname = "import";
+
+ public XmlSchemaImport()
+ {
+ }
+
+ [System.Xml.Serialization.XmlAttribute("namespace")]
+ public string Namespace
+ {
+ get{ return nameSpace; }
+ set{ nameSpace = value; }
+ }
+
+ [XmlElement("annotation",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnnotation Annotation
+ {
+ get{ return annotation; }
+ set{ annotation = value; }
+ }
+ //<import
+ // id = ID
+ // namespace = anyURI
+ // schemaLocation = anyURI
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</import>
+ internal static XmlSchemaImport Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaImport import = new XmlSchemaImport();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "import")
+ {
+ error(h,"Should not happen :1: XmlSchemaImport.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ import.LineNumber = reader.LineNumber;
+ import.LinePosition = reader.LinePosition;
+ import.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ import.Id = reader.Value;
+ }
+ else if(reader.Name == "namespace")
+ {
+ import.nameSpace = reader.Value;
+ }
+ else if(reader.Name == "schemaLocation")
+ {
+ import.SchemaLocation = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for import",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,import);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return import;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaImport.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ import.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return import;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaInclude.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaInclude.cs
new file mode 100755
index 00000000000..8cbb081eb7a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaInclude.cs
@@ -0,0 +1,97 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaInclude.
+ /// </summary>
+ public class XmlSchemaInclude : XmlSchemaExternal
+ {
+ private XmlSchemaAnnotation annotation;
+ private static string xmlname = "include";
+
+ public XmlSchemaInclude()
+ {
+ }
+ [XmlElement("annotation",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnnotation Annotation
+ {
+ get{ return annotation; }
+ set{ annotation = value; }
+ }
+
+ //<include
+ // id = ID
+ // schemaLocation = anyURI
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</include>
+ internal static XmlSchemaInclude Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaInclude include = new XmlSchemaInclude();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaInclude.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ include.LineNumber = reader.LineNumber;
+ include.LinePosition = reader.LinePosition;
+ include.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ include.Id = reader.Value;
+ }
+ else if(reader.Name == "schemaLocation")
+ {
+ include.SchemaLocation = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for include",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,include);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return include;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaInclude.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ include.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+
+ return include;
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaInfo.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaInfo.cs
new file mode 100755
index 00000000000..9fc85b04f26
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaInfo.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Xml;
+using System.Collections;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// This class would store the infomation we need during compilation.
+ /// </summary>
+ internal class XmlSchemaInfo
+ {
+ internal XmlSchemaInfo()
+ {
+ IDCollection = new Hashtable();
+ }
+
+ internal string TargetNamespace = null;
+ internal XmlSchemaDerivationMethod FinalDefault = XmlSchemaDerivationMethod.None;
+ internal XmlSchemaDerivationMethod BlockDefault = XmlSchemaDerivationMethod.None;
+ internal XmlSchemaForm ElementFormDefault = XmlSchemaForm.None;
+ internal XmlSchemaForm AttributeFormDefault = XmlSchemaForm.None;
+ internal Hashtable IDCollection;
+ internal XmlSchemaObjectTable SchemaTypes ;
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaKey.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaKey.cs
new file mode 100755
index 00000000000..b883f9e8da7
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaKey.cs
@@ -0,0 +1,127 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaKey.
+ /// </summary>
+ public class XmlSchemaKey : XmlSchemaIdentityConstraint
+ {
+ private static string xmlname = "key";
+
+ public XmlSchemaKey()
+ {
+ }
+ /// <remarks>
+ /// 1. name must be present
+ /// 2. selector and field must be present
+ /// </remarks>
+ [MonoTODO]
+ internal new int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ return base.Compile(h,info);
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ internal new void error(ValidationEventHandler handle, string message)
+ {
+ errorCount++;
+ ValidationHandler.RaiseValidationError(handle, this, message);
+ }
+
+ //<key
+ // id = ID
+ // name = NCName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (selector, field+))
+ //</key>
+ internal static XmlSchemaKey Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaKey key = new XmlSchemaKey();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaKey.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ key.LineNumber = reader.LineNumber;
+ key.LinePosition = reader.LinePosition;
+ key.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ key.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ key.Name = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for key",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,key);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return key;
+
+ // Content: annotation?, selector, field+
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaKey.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ key.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2 && reader.LocalName == "selector")
+ {
+ level = 3;
+ XmlSchemaXPath selector = XmlSchemaXPath.Read(reader,h,"selector");
+ if(selector != null)
+ key.Selector = selector;
+ continue;
+ }
+ if(level <= 3 && reader.LocalName == "field")
+ {
+ level = 3;
+ if(key.Selector == null)
+ error(h,"selector must be defined before field declarations",null);
+ XmlSchemaXPath field = XmlSchemaXPath.Read(reader,h,"field");
+ if(field != null)
+ key.Fields.Add(field);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return key;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaKeyref.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaKeyref.cs
new file mode 100755
index 00000000000..f22a40f23bd
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaKeyref.cs
@@ -0,0 +1,151 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaKeyref.
+ /// </summary>
+ public class XmlSchemaKeyref : XmlSchemaIdentityConstraint
+ {
+ private XmlQualifiedName refer;
+ private static string xmlname = "keyref";
+
+ public XmlSchemaKeyref()
+ {
+ refer = XmlQualifiedName.Empty;
+ }
+
+ [System.Xml.Serialization.XmlAttribute("refer")]
+ public XmlQualifiedName Refer
+ {
+ get{ return refer; }
+ set{ refer = value; }
+ }
+ /// <remarks>
+ /// 1. name must be present
+ /// 2. selector and field must be present
+ /// 3. refer must be present
+ /// </remarks>
+ [MonoTODO]
+ internal new int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount += base.Compile(h,info);
+ if(refer == null || refer.IsEmpty)
+ error(h,"refer must be present");
+ else if(!XmlSchemaUtil.CheckQName(refer))
+ error(h,"Refer is not a valid XmlQualifiedName");
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ internal new void error(ValidationEventHandler handle, string message)
+ {
+ errorCount++;
+ ValidationHandler.RaiseValidationError(handle, this, message);
+ }
+ //<key
+ // id = ID
+ // name = NCName
+ // refer = QName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (selector, field+))
+ //</key>
+ internal static XmlSchemaKeyref Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaKeyref keyref = new XmlSchemaKeyref();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaKeyref.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ keyref.LineNumber = reader.LineNumber;
+ keyref.LinePosition = reader.LinePosition;
+ keyref.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ keyref.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ keyref.Name = reader.Value;
+ }
+ else if(reader.Name == "refer")
+ {
+ Exception innerex;
+ keyref.refer = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for refer attribute",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for keyref",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,keyref);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return keyref;
+
+ // Content: annotation?, selector, field+
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaKeyref.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ keyref.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2 && reader.LocalName == "selector")
+ {
+ level = 3;
+ XmlSchemaXPath selector = XmlSchemaXPath.Read(reader,h,"selector");
+ if(selector != null)
+ keyref.Selector = selector;
+ continue;
+ }
+ if(level <= 3 && reader.LocalName == "field")
+ {
+ level = 3;
+ if(keyref.Selector == null)
+ error(h,"selector must be defined before field declarations",null);
+ XmlSchemaXPath field = XmlSchemaXPath.Read(reader,h,"field");
+ if(field != null)
+ keyref.Fields.Add(field);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return keyref;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaLengthFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaLengthFacet.cs
new file mode 100755
index 00000000000..263d3c1c58e
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaLengthFacet.cs
@@ -0,0 +1,96 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaLengthFacet.
+ /// </summary>
+ public class XmlSchemaLengthFacet : XmlSchemaNumericFacet
+ {
+ private static string xmlname = "length";
+
+ public XmlSchemaLengthFacet()
+ {
+ }
+
+ //<length
+ // fixed = boolean : false
+ // id = ID
+ // value = nonNegativeInteger
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</length>
+ internal static XmlSchemaLengthFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaLengthFacet length = new XmlSchemaLengthFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaLengthFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ length.LineNumber = reader.LineNumber;
+ length.LinePosition = reader.LinePosition;
+ length.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ length.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ length.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ length.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for group",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,length);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return length;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaLengthFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ length.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return length;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.cs
new file mode 100755
index 00000000000..258c5bf9ccc
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.cs
@@ -0,0 +1,96 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaMaxExclusiveFacet.
+ /// </summary>
+ public class XmlSchemaMaxExclusiveFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "maxExclusive";
+
+ public XmlSchemaMaxExclusiveFacet()
+ {
+ }
+
+ //<maxExclusive
+ // fixed = boolean : false
+ // id = ID
+ // value = anySimpleType
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</maxExclusive>
+ internal static XmlSchemaMaxExclusiveFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaMaxExclusiveFacet maxex = new XmlSchemaMaxExclusiveFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaMaxExclusiveFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ maxex.LineNumber = reader.LineNumber;
+ maxex.LinePosition = reader.LinePosition;
+ maxex.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ maxex.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ maxex.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ maxex.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,maxex);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return maxex;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaMaxExclusiveFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ maxex.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return maxex;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.cs
new file mode 100755
index 00000000000..c080abad8d9
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.cs
@@ -0,0 +1,96 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaMaxInclusiveFacet.
+ /// </summary>
+ public class XmlSchemaMaxInclusiveFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "maxInclusive";
+
+ public XmlSchemaMaxInclusiveFacet()
+ {
+ }
+
+ //<maxInclusive
+ // fixed = boolean : false
+ // id = ID
+ // value = anySimpleType
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</maxInclusive>
+ internal static XmlSchemaMaxInclusiveFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaMaxInclusiveFacet maxi = new XmlSchemaMaxInclusiveFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaMaxInclusiveFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ maxi.LineNumber = reader.LineNumber;
+ maxi.LinePosition = reader.LinePosition;
+ maxi.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ maxi.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ maxi.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ maxi.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,maxi);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return maxi;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaMaxInclusiveFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ maxi.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return maxi;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxLengthFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxLengthFacet.cs
new file mode 100755
index 00000000000..a7bbb98b145
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxLengthFacet.cs
@@ -0,0 +1,97 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaMaxLengthFacet.
+ /// </summary>
+ public class XmlSchemaMaxLengthFacet : XmlSchemaNumericFacet
+ {
+ private static string xmlname = "maxLength";
+
+ public XmlSchemaMaxLengthFacet()
+ {
+ }
+
+ //<maxLength
+ // fixed = boolean : false
+ // id = ID
+ // value = nonNegativeInteger
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</maxLength>
+ internal static XmlSchemaMaxLengthFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaMaxLengthFacet length = new XmlSchemaMaxLengthFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaMaxLengthFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ length.LineNumber = reader.LineNumber;
+ length.LinePosition = reader.LinePosition;
+ length.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ length.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ length.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ length.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for group",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,length);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return length;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaMaxLengthFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ length.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return length;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinExclusiveFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinExclusiveFacet.cs
new file mode 100755
index 00000000000..ea0cda2c7fa
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinExclusiveFacet.cs
@@ -0,0 +1,96 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaMinExclusiveFacet.
+ /// </summary>
+ public class XmlSchemaMinExclusiveFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "minExclusive";
+
+ public XmlSchemaMinExclusiveFacet()
+ {
+ }
+
+ //<minExclusive
+ // fixed = boolean : false
+ // id = ID
+ // value = anySimpleType
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</minExclusive>
+ internal static XmlSchemaMinExclusiveFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaMinExclusiveFacet minex = new XmlSchemaMinExclusiveFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaMinExclusiveFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ minex.LineNumber = reader.LineNumber;
+ minex.LinePosition = reader.LinePosition;
+ minex.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ minex.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ minex.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ minex.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,minex);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return minex;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaMinExclusiveFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ minex.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return minex;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinInclusiveFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinInclusiveFacet.cs
new file mode 100755
index 00000000000..8459cd3ebe5
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinInclusiveFacet.cs
@@ -0,0 +1,95 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaMinInclusiveFacet.
+ /// </summary>
+ public class XmlSchemaMinInclusiveFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "minInclusive";
+
+ public XmlSchemaMinInclusiveFacet()
+ {
+ }
+ //<minInclusive
+ // fixed = boolean : false
+ // id = ID
+ // value = anySimpleType
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</minInclusive>
+ internal static XmlSchemaMinInclusiveFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaMinInclusiveFacet mini = new XmlSchemaMinInclusiveFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaMinInclusiveFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ mini.LineNumber = reader.LineNumber;
+ mini.LinePosition = reader.LinePosition;
+ mini.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ mini.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ mini.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ mini.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,mini);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return mini;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaMinInclusiveFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ mini.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return mini;
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinLengthFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinLengthFacet.cs
new file mode 100755
index 00000000000..51763977a4a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinLengthFacet.cs
@@ -0,0 +1,96 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaMinLengthFacet.
+ /// </summary>
+ public class XmlSchemaMinLengthFacet : XmlSchemaNumericFacet
+ {
+ private static string xmlname = "minLength";
+
+ public XmlSchemaMinLengthFacet()
+ {
+ }
+
+ //<minLength
+ // fixed = boolean : false
+ // id = ID
+ // value = nonNegativeInteger
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</minLength>
+ internal static XmlSchemaMinLengthFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaMinLengthFacet length = new XmlSchemaMinLengthFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaMinLengthFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ length.LineNumber = reader.LineNumber;
+ length.LinePosition = reader.LinePosition;
+ length.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ length.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ length.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ length.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,length);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return length;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaMinLengthFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ length.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return length;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaNotation.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaNotation.cs
new file mode 100755
index 00000000000..f07b83213c5
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaNotation.cs
@@ -0,0 +1,158 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaNotation.
+ /// </summary>
+ public class XmlSchemaNotation : XmlSchemaAnnotated
+ {
+ private string name;
+ private string pub;
+ private string system;
+ private XmlQualifiedName qualifiedName;
+ private static string xmlname = "notation";
+
+ public XmlSchemaNotation()
+ {
+ }
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name; }
+ set{ name = value; }
+ }
+ [System.Xml.Serialization.XmlAttribute("public")]
+ public string Public
+ {
+ get{ return pub; }
+ set{ pub = value; }
+ }
+ [System.Xml.Serialization.XmlAttribute("system")]
+ public string System
+ {
+ get{ return system; }
+ set{ system = value; }
+ }
+
+ [XmlIgnore]
+ internal XmlQualifiedName QualifiedName
+ {
+ get{ return qualifiedName;}
+ }
+
+ // 1. name and public must be present
+ // public and system must be anyURI
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(Name == null)
+ error(h,"Required attribute name must be present");
+ else if(!XmlSchemaUtil.CheckNCName(this.name))
+ error(h,"attribute name must be NCName");
+ else
+ qualifiedName = new XmlQualifiedName(Name,info.TargetNamespace);
+
+ if(Public==null)
+ error(h,"public must be present");
+ else if(!XmlSchemaUtil.CheckAnyUri(Public))
+ error(h,"public must be anyURI");
+
+ if(system != null && !XmlSchemaUtil.CheckAnyUri(system))
+ error(h,"system must be present and of Type anyURI");
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<notation
+ // id = ID
+ // name = NCName
+ // public = anyURI
+ // system = anyURI
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</notation>
+ internal static XmlSchemaNotation Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaNotation notation = new XmlSchemaNotation();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaInclude.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ notation.LineNumber = reader.LineNumber;
+ notation.LinePosition = reader.LinePosition;
+ notation.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ notation.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ notation.name = reader.Value;
+ }
+ else if(reader.Name == "public")
+ {
+ notation.pub = reader.Value;
+ }
+ else if(reader.Name == "system")
+ {
+ notation.system = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for notation",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,notation);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return notation;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaNotation.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ notation.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return notation;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaNumericFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaNumericFacet.cs
new file mode 100755
index 00000000000..72359a71f16
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaNumericFacet.cs
@@ -0,0 +1,16 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaNumericFacet.
+ /// </summary>
+ public abstract class XmlSchemaNumericFacet : XmlSchemaFacet
+ {
+ protected XmlSchemaNumericFacet()
+ {
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObject.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObject.cs
new file mode 100755
index 00000000000..71e8b57faf4
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObject.cs
@@ -0,0 +1,75 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaObject.
+ /// </summary>
+ public abstract class XmlSchemaObject
+ {
+ private int lineNumber;
+ private int linePosition;
+ private string sourceUri;
+ private XmlSerializerNamespaces namespaces;
+ internal ArrayList unhandledAttributeList ;
+ internal bool isCompiled = false;
+ internal int errorCount = 0;
+
+ protected XmlSchemaObject()
+ {
+ namespaces = new XmlSerializerNamespaces();
+ unhandledAttributeList = null;
+ }
+
+ [XmlIgnore]
+ public int LineNumber
+ {
+ get{ return lineNumber; }
+ set{ lineNumber = value; }
+ }
+ [XmlIgnore]
+ public int LinePosition
+ {
+ get{ return linePosition; }
+ set{ linePosition = value; }
+ }
+ [XmlIgnore]
+ public string SourceUri
+ {
+ get{ return sourceUri; }
+ set{ sourceUri = value; }
+ }
+
+ // Undocumented Property
+ [XmlNamespaceDeclarations]
+ public XmlSerializerNamespaces Namespaces
+ {
+ get{ return namespaces; }
+ set{ namespaces = value; }
+ }
+
+ internal void error(ValidationEventHandler handle,string message)
+ {
+ errorCount++;
+ ValidationHandler.RaiseValidationError(handle,this,message);
+ }
+ internal void warn(ValidationEventHandler handle,string message)
+ {
+ errorCount++;
+ ValidationHandler.RaiseValidationWarning(handle,this,message);
+ }
+ internal static void error(ValidationEventHandler handle, string message, Exception innerException)
+ {
+ ValidationHandler.RaiseValidationError(handle,message, innerException);
+ }
+ internal static void warn(ValidationEventHandler handle, string message, Exception innerException)
+ {
+ ValidationHandler.RaiseValidationWarning(handle,message, innerException);
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectCollection.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectCollection.cs
new file mode 100755
index 00000000000..874c5c13830
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectCollection.cs
@@ -0,0 +1,88 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaObjectCollection.
+ /// </summary>
+ public class XmlSchemaObjectCollection : System.Collections.CollectionBase
+ {
+ private XmlSchemaObject parent;
+
+ public XmlSchemaObjectCollection()
+ {
+ }
+ public XmlSchemaObjectCollection(XmlSchemaObject parent)
+ {
+ this.parent = parent;
+ }
+
+ // Properties
+ public virtual XmlSchemaObject this[ int index ]
+ {
+ get
+ {
+ return (XmlSchemaObject) this.List[index];
+ }
+ set
+ {
+ this.List[index] = value;
+ }
+ }
+
+ // Methods
+ public int Add(XmlSchemaObject item)
+ {
+ return this.List.Add(item);
+ }
+
+ public bool Contains(XmlSchemaObject item)
+ {
+ return this.List.Contains(item);
+ }
+
+ public void CopyTo(XmlSchemaObject[] array, int index)
+ {
+ this.List.CopyTo(array,index);
+ }
+
+ public new XmlSchemaObjectEnumerator GetEnumerator ()
+ {
+ return new XmlSchemaObjectEnumerator(this.List);
+ }
+
+ public int IndexOf(XmlSchemaObject item)
+ {
+ return this.List.IndexOf(item);
+ }
+
+ public void Insert(int index, XmlSchemaObject item)
+ {
+ this.List.Insert(index, item);
+ }
+
+ protected override void OnClear()
+ {
+ }
+
+ protected override void OnInsert(int index,object item)
+ {
+ }
+
+ protected override void OnRemove(int index,object item)
+ {
+ }
+
+ protected override void OnSet(int index,object oldValue,object newValue)
+ {
+ }
+
+ public void Remove(XmlSchemaObject item)
+ {
+ this.List.Remove(item);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectEnumerator.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectEnumerator.cs
new file mode 100755
index 00000000000..6c2af9513d5
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectEnumerator.cs
@@ -0,0 +1,49 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaObjectEnumerator.
+ /// </summary>
+ public sealed class XmlSchemaObjectEnumerator : IEnumerator
+ {
+ private IEnumerator ienum;
+ internal XmlSchemaObjectEnumerator(IList list)
+ {
+ this.ienum = list.GetEnumerator();
+ }
+ // Properties
+ public XmlSchemaObject Current
+ {
+ get
+ {
+ return (XmlSchemaObject) ienum.Current;
+ }
+ }
+ // Methods
+ public bool MoveNext()
+ {
+ return ienum.MoveNext();
+ }
+ public void Reset()
+ {
+ ienum.Reset();
+ }
+ //Explicit Interface implementation
+ bool IEnumerator.MoveNext()
+ {
+ return ienum.MoveNext();
+ }
+ void IEnumerator.Reset()
+ {
+ ienum.Reset();
+ }
+ object IEnumerator.Current
+ {
+ get{return (XmlSchema) ienum.Current;}
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectTable.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectTable.cs
new file mode 100755
index 00000000000..16461b9875c
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectTable.cs
@@ -0,0 +1,51 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaObjectTable.
+ /// </summary>
+ public class XmlSchemaObjectTable
+ {
+ private Hashtable table;
+
+ internal XmlSchemaObjectTable()
+ {
+ table = new Hashtable();
+ }
+ public int Count
+ {
+ get{ return table.Count; }
+ }
+ public XmlSchemaObject this[XmlQualifiedName name]
+ {
+ get{ return (XmlSchemaObject) table[name]; }
+ }
+ public ICollection Names
+ {
+ get{ return table.Keys; }
+ }
+ public ICollection Values
+ {
+ get{ return table.Values;}
+ }
+
+ public bool Contains(XmlQualifiedName name)
+ {
+ return table.Contains(name);
+ }
+ public IDictionaryEnumerator GetEnumerator()
+ {
+ return table.GetEnumerator();
+ }
+
+ internal void Add(XmlQualifiedName name, XmlSchemaObject value)
+ {
+ table.Add(name,value);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaParticle.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaParticle.cs
new file mode 100755
index 00000000000..119c335b3c0
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaParticle.cs
@@ -0,0 +1,98 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaParticle.
+ /// </summary>
+ public abstract class XmlSchemaParticle : XmlSchemaAnnotated
+ {
+ decimal minOccurs, maxOccurs;
+ string minstr, maxstr;
+
+ protected XmlSchemaParticle()
+ {
+ minOccurs = decimal.One;
+ maxOccurs = decimal.One;
+ }
+
+ #region Attributes
+
+ [System.Xml.Serialization.XmlAttribute("minOccurs")]
+ public string MinOccursString
+ {
+ get{ return minstr; }
+ set
+ {
+ decimal val = decimal.Parse(value);
+ if(val >= 0 && (val == Decimal.Truncate(val)))
+ {
+ minOccurs = val;
+ minstr = val.ToString();
+ }
+ else
+ {
+ throw new XmlSchemaException
+ ("MinOccursString must be a non-negative number",null);
+ }
+ }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("maxOccurs")]
+ public string MaxOccursString
+ {
+ get{ return maxstr; }
+ set
+ {
+ if(value == "unbounded")
+ {
+ maxstr = value;
+ maxOccurs = decimal.MaxValue;
+ }
+ else
+ {
+ decimal val = decimal.Parse(value);
+ if(val >= 0 && (val == Decimal.Truncate(val)))
+ {
+ maxOccurs = val;
+ maxstr = val.ToString();
+ }
+ else
+ {
+ throw new XmlSchemaException
+ ("MaxOccurs must be a non-negative integer",null);
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region XmlIgnore
+
+ [XmlIgnore]
+ public decimal MinOccurs
+ {
+ get{ return minOccurs; }
+ set
+ {
+ MinOccursString = value.ToString();
+ }
+ }
+
+ [XmlIgnore]
+ public decimal MaxOccurs
+ {
+ get{ return maxOccurs; }
+ set
+ {
+ MaxOccursString = value.ToString();
+ }
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaPatternFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaPatternFacet.cs
new file mode 100755
index 00000000000..da2effbb380
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaPatternFacet.cs
@@ -0,0 +1,87 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaPatternFacet.
+ /// </summary>
+ public class XmlSchemaPatternFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "pattern";
+
+ public XmlSchemaPatternFacet()
+ {
+ }
+ //<pattern
+ // id = ID
+ // value = anySimpleType
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</pattern>
+ internal static XmlSchemaPatternFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaPatternFacet pattern = new XmlSchemaPatternFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaPatternFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ pattern.LineNumber = reader.LineNumber;
+ pattern.LinePosition = reader.LinePosition;
+ pattern.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ pattern.Id = reader.Value;
+ }
+ else if(reader.Name == "value")
+ {
+ pattern.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,pattern);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return pattern;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaPatternFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ pattern.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return pattern;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaReader.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaReader.cs
new file mode 100755
index 00000000000..fc4375a9767
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaReader.cs
@@ -0,0 +1,358 @@
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// A wrapper around XmlReader
+ /// </summary>
+ public class XmlSchemaReader : XmlReader, IXmlLineInfo
+ {
+ XmlReader reader;
+ ValidationEventHandler handler;
+ bool hasLineInfo;
+ public XmlSchemaReader(XmlReader reader,ValidationEventHandler handler)
+ {
+ this.reader = reader;
+ this.handler = handler;
+ if(reader is IXmlLineInfo)
+ {
+ IXmlLineInfo info = (IXmlLineInfo)reader;
+ hasLineInfo = info.HasLineInfo();
+ }
+ }
+
+ /// <summary>
+ /// Returns the Namespace:LocalName for the object
+ /// </summary>
+ public string FullName
+ {
+ get { return NamespaceURI + ":" + LocalName; }
+ }
+
+ public void RaiseInvalidElementError()
+ {
+ string errstr = "Element "+FullName + " is invalid in this context.\n";
+ if(hasLineInfo)
+ errstr += "The error occured on ("+((IXmlLineInfo)reader).LineNumber
+ +","+((IXmlLineInfo)reader).LinePosition+")";
+ XmlSchemaObject.error(handler, errstr, null);
+ SkipToEnd();
+ }
+ /// <summary>
+ /// Reads till the next Element or EndElement. Also checks that the Namespace of the element is
+ /// Schema's Namespace.
+ /// </summary>
+ /// <returns></returns>
+ public bool ReadNextElement()
+ {
+ MoveToElement();
+ while(Read())
+ {
+ if(NodeType == XmlNodeType.Element || NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.NamespaceURI != XmlSchema.Namespace)
+ {
+ RaiseInvalidElementError();
+ }
+ else
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// Skips to the end of the current element
+ /// </summary>
+ public void SkipToEnd()
+ {
+ MoveToElement();
+ if(IsEmptyElement || NodeType != XmlNodeType.Element)
+ return;
+ if(NodeType == XmlNodeType.Element)
+ {
+ int depth = Depth;
+ while(Read())
+ {
+ if(Depth == depth)
+ break;
+ }
+ }
+ return;
+ }
+
+ #region LineInfo
+ public bool HasLineInfo()
+ {
+ return hasLineInfo;
+ }
+ public int LineNumber
+ {
+ get { return hasLineInfo?((IXmlLineInfo)reader).LineNumber: 0; }
+ }
+ public int LinePosition
+ {
+ get { return hasLineInfo?((IXmlLineInfo)reader).LinePosition: 0; }
+ }
+ #endregion
+
+ #region Delegates
+ public override int AttributeCount
+ {
+ get { return reader.AttributeCount; }
+ }
+ public override string BaseURI
+ {
+ get { return reader.BaseURI; }
+ }
+ public override bool CanResolveEntity
+ {
+ get { return reader.CanResolveEntity; }
+ }
+ public override int Depth
+ {
+ get { return reader.Depth; }
+ }
+ public override bool EOF
+ {
+ get { return reader.EOF; }
+ }
+ public override bool HasAttributes
+ {
+ get { return reader.HasAttributes; }
+ }
+ public override bool HasValue
+ {
+ get { return reader.HasValue; }
+ }
+ public override bool IsDefault
+ {
+ get { return reader.IsDefault; }
+ }
+ public override bool IsEmptyElement
+ {
+ get { return reader.IsEmptyElement; }
+ }
+ public override string this[ int i ]
+ {
+ get { return reader[i]; }
+ }
+ public override string this[ string name ]
+ {
+ get { return reader[name]; }
+ }
+ public override string this[ string name, string namespaceURI ]
+ {
+ get { return reader[name,namespaceURI]; }
+ }
+ public override string LocalName
+ {
+ get { return reader.LocalName; }
+ }
+ public override string Name
+ {
+ get { return reader.Name; }
+ }
+ public override string NamespaceURI
+ {
+ get { return reader.NamespaceURI; }
+ }
+ public override XmlNameTable NameTable
+ {
+ get { return reader.NameTable; }
+ }
+ public override XmlNodeType NodeType
+ {
+ get { return reader.NodeType; }
+ }
+ public override string Prefix
+ {
+ get { return reader.Prefix; }
+ }
+ public override char QuoteChar
+ {
+ get { return reader.QuoteChar; }
+ }
+ public override ReadState ReadState
+ {
+ get { return reader.ReadState; }
+ }
+ public override string Value
+ {
+ get { return reader.Value; }
+ }
+ public override string XmlLang
+ {
+ get { return reader.XmlLang; }
+ }
+ public override XmlSpace XmlSpace
+ {
+ get { return reader.XmlSpace; }
+ }
+
+ public override void Close()
+ {
+ reader.Close();
+ }
+
+ public override bool Equals(object obj)
+ {
+ return reader.Equals(obj);
+ }
+
+ public override string GetAttribute(int i)
+ {
+ return reader.GetAttribute(i);
+ }
+
+ public override string GetAttribute(string name)
+ {
+ return reader.GetAttribute(name);
+ }
+
+ public override string GetAttribute(string name, string namespaceURI)
+ {
+ return reader.GetAttribute(name, namespaceURI);
+ }
+
+ public override int GetHashCode()
+ {
+ return reader.GetHashCode();
+ }
+
+ public override bool IsStartElement()
+ {
+ return reader.IsStartElement();
+ }
+
+ public override bool IsStartElement(string localname, string ns)
+ {
+ return reader.IsStartElement(localname, ns);
+ }
+
+ public override bool IsStartElement(string name)
+ {
+ return reader.IsStartElement(name);
+ }
+
+ public override string LookupNamespace(string prefix)
+ {
+ return reader.LookupNamespace(prefix);
+ }
+
+ public override void MoveToAttribute(int i)
+ {
+ reader.MoveToAttribute(i);
+ }
+
+ public override bool MoveToAttribute(string name)
+ {
+ return reader.MoveToAttribute(name);
+ }
+
+ public override bool MoveToAttribute(string name, string ns)
+ {
+ return reader.MoveToAttribute(name,ns);
+ }
+
+ public override System.Xml.XmlNodeType MoveToContent()
+ {
+ return reader.MoveToContent();
+ }
+
+ public override bool MoveToElement()
+ {
+ return reader.MoveToElement();
+ }
+
+ public override bool MoveToFirstAttribute()
+ {
+ return reader.MoveToFirstAttribute();
+ }
+
+ public override bool MoveToNextAttribute()
+ {
+ return reader.MoveToNextAttribute();
+ }
+
+ public override bool Read()
+ {
+ return reader.Read();
+ }
+
+ public override bool ReadAttributeValue()
+ {
+ return reader.ReadAttributeValue();
+ }
+
+ public override string ReadElementString()
+ {
+ return reader.ReadElementString();
+ }
+
+ public override string ReadElementString(string localname, string ns)
+ {
+ return reader.ReadElementString(localname, ns);
+ }
+
+ public override string ReadElementString(string name)
+ {
+ return reader.ReadElementString(name);
+ }
+
+ public override void ReadEndElement()
+ {
+ reader.ReadEndElement();
+ }
+
+ public override string ReadInnerXml()
+ {
+ return reader.ReadInnerXml();
+ }
+
+ public override string ReadOuterXml()
+ {
+ return reader.ReadOuterXml();
+ }
+
+ public override void ReadStartElement()
+ {
+ reader.ReadStartElement();
+ }
+
+ public override void ReadStartElement(string localname, string ns)
+ {
+ reader.ReadStartElement(localname, ns);
+ }
+
+ public override void ReadStartElement(string name)
+ {
+ reader.ReadStartElement(name);
+ }
+
+ public override string ReadString()
+ {
+ return reader.ReadString();
+ }
+
+ public override void ResolveEntity()
+ {
+ reader.ResolveEntity();
+ }
+
+ public override void Skip()
+ {
+ reader.Skip();
+ }
+
+ public override string ToString()
+ {
+ return reader.ToString();
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaRedefine.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaRedefine.cs
new file mode 100755
index 00000000000..bd573ec94ab
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaRedefine.cs
@@ -0,0 +1,151 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaRedefine.
+ /// </summary>
+ public class XmlSchemaRedefine : XmlSchemaExternal
+ {
+ private XmlSchemaObjectTable attributeGroups;
+ private XmlSchemaObjectTable groups;
+ private XmlSchemaObjectCollection items;
+ private XmlSchemaObjectTable schemaTypes;
+ private static string xmlname = "redefine";
+
+ public XmlSchemaRedefine()
+ {
+ attributeGroups = new XmlSchemaObjectTable();
+ groups = new XmlSchemaObjectTable();
+ items = new XmlSchemaObjectCollection(this);
+ schemaTypes = new XmlSchemaObjectTable();
+ }
+
+ [XmlElement("annotation",typeof(XmlSchemaAnnotation),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("complexType",typeof(XmlSchemaComplexType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("group",typeof(XmlSchemaGroup),Namespace="http://www.w3.org/2001/XMLSchema")]
+ //NOTE: AttributeGroup and not AttributeGroupRef
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroup),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Items
+ {
+ get{ return items; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable AttributeGroups
+ {
+ get{ return attributeGroups; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable SchemaTypes
+ {
+ get{ return schemaTypes; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable Groups
+ {
+ get{ return groups; }
+ }
+//<redefine
+// id = ID
+// schemaLocation = anyURI
+// {any attributes with non-schema namespace . . .}>
+// Content: (annotation | (simpleType | complexType | group | attributeGroup))*
+//</redefine>
+ internal static XmlSchemaRedefine Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaRedefine redefine = new XmlSchemaRedefine();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaRedefine.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ redefine.LineNumber = reader.LineNumber;
+ redefine.LinePosition = reader.LinePosition;
+ redefine.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ redefine.Id = reader.Value;
+ }
+ else if(reader.Name == "schemaLocation")
+ {
+ redefine.SchemaLocation = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for redefine",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,redefine);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return redefine;
+
+ //(annotation | (simpleType | complexType | group | attributeGroup))*
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaRedefine.Read, name="+reader.Name,null);
+ break;
+ }
+ if(reader.LocalName == "annotation")
+ {
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ redefine.items.Add(annotation);
+ continue;
+ }
+ if(reader.LocalName == "simpleType")
+ {
+ XmlSchemaSimpleType simpleType = XmlSchemaSimpleType.Read(reader,h);
+ if(simpleType != null)
+ redefine.items.Add(simpleType);
+ continue;
+ }
+ if(reader.LocalName == "complexType")
+ {
+ XmlSchemaComplexType complexType = XmlSchemaComplexType.Read(reader,h);
+ if(complexType != null)
+ redefine.items.Add(complexType);
+ continue;
+ }
+ if(reader.LocalName == "group")
+ {
+ XmlSchemaGroup group = XmlSchemaGroup.Read(reader,h);
+ if(group != null)
+ redefine.items.Add(group);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ XmlSchemaAttributeGroup attributeGroup = XmlSchemaAttributeGroup.Read(reader,h);
+ if(attributeGroup != null)
+ redefine.items.Add(attributeGroup);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return redefine;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSequence.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSequence.cs
new file mode 100755
index 00000000000..769ab66f2b7
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSequence.cs
@@ -0,0 +1,202 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSequence.
+ /// </summary>
+ public class XmlSchemaSequence : XmlSchemaGroupBase
+ {
+ private XmlSchemaObjectCollection items;
+ private static string xmlname = "sequence";
+
+ public XmlSchemaSequence()
+ {
+ items = new XmlSchemaObjectCollection();
+ }
+
+ [XmlElement("element",typeof(XmlSchemaElement),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("any",typeof(XmlSchemaAny),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public override XmlSchemaObjectCollection Items
+ {
+ get{ return items; }
+ }
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ //FIXME: Should we reset the values
+ if(MinOccurs > MaxOccurs)
+ error(h,"minOccurs must be less than or equal to maxOccurs");
+
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);
+
+ foreach(XmlSchemaObject obj in Items)
+ {
+ if(obj is XmlSchemaElement)
+ {
+ errorCount += ((XmlSchemaElement)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaGroupRef)
+ {
+ errorCount += ((XmlSchemaGroupRef)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaChoice)
+ {
+ errorCount += ((XmlSchemaChoice)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaSequence)
+ {
+ errorCount += ((XmlSchemaSequence)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaAny)
+ {
+ errorCount += ((XmlSchemaAny)obj).Compile(h,info);
+ }
+ }
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<sequence
+ // id = ID
+ // maxOccurs = (nonNegativeInteger | unbounded) : 1
+ // minOccurs = nonNegativeInteger : 1
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (element | group | choice | sequence | any)*)
+ //</sequence>
+ internal static XmlSchemaSequence Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSequence sequence = new XmlSchemaSequence();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaSequence.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ sequence.LineNumber = reader.LineNumber;
+ sequence.LinePosition = reader.LinePosition;
+ sequence.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ sequence.Id = reader.Value;
+ }
+ else if(reader.Name == "maxOccurs")
+ {
+ try
+ {
+ sequence.MaxOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for maxOccurs",e);
+ }
+ }
+ else if(reader.Name == "minOccurs")
+ {
+ try
+ {
+ sequence.MinOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for minOccurs",e);
+ }
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for sequence",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,sequence);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return sequence;
+
+ // Content: (annotation?, (element | group | choice | sequence | any)*)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSequence.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ sequence.Annotation = annotation;
+ continue;
+ }
+ if(level <=2)
+ {
+ if(reader.LocalName == "element")
+ {
+ level = 2;
+ XmlSchemaElement element = XmlSchemaElement.Read(reader,h);
+ if(element != null)
+ sequence.items.Add(element);
+ continue;
+ }
+ if(reader.LocalName == "group")
+ {
+ level = 2;
+ XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h);
+ if(group != null)
+ sequence.items.Add(group);
+ continue;
+ }
+ if(reader.LocalName == "choice")
+ {
+ level = 2;
+ XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h);
+ if(choice != null)
+ sequence.items.Add(choice);
+ continue;
+ }
+ if(reader.LocalName == "sequence")
+ {
+ level = 2;
+ XmlSchemaSequence seq = XmlSchemaSequence.Read(reader,h);
+ if(seq != null)
+ sequence.items.Add(seq);
+ continue;
+ }
+ if(reader.LocalName == "any")
+ {
+ level = 2;
+ XmlSchemaAny any = XmlSchemaAny.Read(reader,h);
+ if(any != null)
+ sequence.items.Add(any);
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return sequence;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContent.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContent.cs
new file mode 100755
index 00000000000..2c2fce3f933
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContent.cs
@@ -0,0 +1,146 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleContent.
+ /// </summary>
+ public class XmlSchemaSimpleContent : XmlSchemaContentModel
+ {
+ private XmlSchemaContent content;
+ private static string xmlname = "simpleContent";
+ public XmlSchemaSimpleContent()
+ {
+ }
+
+ [XmlElement("restriction",typeof(XmlSchemaSimpleContentRestriction),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("extension",typeof(XmlSchemaSimpleContentExtension),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public override XmlSchemaContent Content
+ {
+ get{ return content; }
+ set{ content = value; }
+ }
+
+ ///<remarks>
+ /// 1. Content must be present and one of restriction or extention
+ ///</remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(Content == null)
+ {
+ error(h, "Content must be present in a simpleContent");
+ }
+ else
+ {
+ if(Content is XmlSchemaSimpleContentRestriction)
+ {
+ XmlSchemaSimpleContentRestriction xscr = (XmlSchemaSimpleContentRestriction) Content;
+ errorCount += xscr.Compile(h,info);
+ }
+ else if(Content is XmlSchemaSimpleContentExtension)
+ {
+ XmlSchemaSimpleContentExtension xsce = (XmlSchemaSimpleContentExtension) Content;
+ errorCount += xsce.Compile(h,info);
+ }
+ else
+ error(h,"simpleContent can't have any value other than restriction or extention");
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<simpleContent
+ // id = ID
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (restriction | extension))
+ //</simpleContent>
+ internal static XmlSchemaSimpleContent Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleContent simple = new XmlSchemaSimpleContent();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexContent.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ simple.LineNumber = reader.LineNumber;
+ simple.LinePosition = reader.LinePosition;
+ simple.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ simple.Id = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for simpleContent",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,simple);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return simple;
+ //Content: (annotation?, (restriction | extension))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleContent.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ simple.Annotation = annotation;
+ continue;
+ }
+ if(level <=2)
+ {
+ if(reader.LocalName == "restriction")
+ {
+ level = 3;
+ XmlSchemaSimpleContentRestriction restriction = XmlSchemaSimpleContentRestriction.Read(reader,h);
+ if(restriction != null)
+ simple.content = restriction;
+ continue;
+ }
+ if(reader.LocalName == "extension")
+ {
+ level = 3;
+ XmlSchemaSimpleContentExtension extension = XmlSchemaSimpleContentExtension.Read(reader,h);
+ if(extension != null)
+ simple.content = extension;
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return simple;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentExtension.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentExtension.cs
new file mode 100755
index 00000000000..09d10f25ef6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentExtension.cs
@@ -0,0 +1,190 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleContentExtension.
+ /// </summary>
+ public class XmlSchemaSimpleContentExtension : XmlSchemaContent
+ {
+
+ private XmlSchemaAnyAttribute any;
+ private XmlSchemaObjectCollection attributes;
+ private XmlQualifiedName baseTypeName;
+ private static string xmlname = "extension";
+
+ public XmlSchemaSimpleContentExtension()
+ {
+ baseTypeName = XmlQualifiedName.Empty;
+ attributes = new XmlSchemaObjectCollection();
+ }
+
+ [System.Xml.Serialization.XmlAttribute("base")]
+ public XmlQualifiedName BaseTypeName
+ {
+ get{ return baseTypeName; }
+ set{ baseTypeName = value; }
+ }
+
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Attributes
+ {
+ get{ return attributes; }
+ }
+
+ [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnyAttribute AnyAttribute
+ {
+ get{ return any; }
+ set{ any = value; }
+ }
+
+ ///<remarks>
+ /// 1. Base must be present and a QName
+ ///</remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(BaseTypeName == null || BaseTypeName.IsEmpty)
+ {
+ error(h, "base must be present and a QName");
+ }
+ else if(!XmlSchemaUtil.CheckQName(BaseTypeName))
+ error(h,"BaseTypeName must be a QName");
+
+ if(this.AnyAttribute != null)
+ {
+ errorCount += AnyAttribute.Compile(h,info);
+ }
+
+ foreach(XmlSchemaObject obj in Attributes)
+ {
+ if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ errorCount += attr.Compile(h,info);
+ }
+ else if(obj is XmlSchemaAttributeGroupRef)
+ {
+ XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;
+ errorCount += atgrp.Compile(h,info);
+ }
+ else
+ error(h,obj.GetType() +" is not valid in this place::SimpleConentExtension");
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<extension
+ //base = QName
+ //id = ID
+ //{any attributes with non-schema namespace . . .}>
+ //Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?))
+ //</extension>
+ internal static XmlSchemaSimpleContentExtension Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleContentExtension extension = new XmlSchemaSimpleContentExtension();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAttributeGroup.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ extension.LineNumber = reader.LineNumber;
+ extension.LinePosition = reader.LinePosition;
+ extension.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "base")
+ {
+ Exception innerex;
+ extension.baseTypeName= XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for base attribute",innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ extension.Id = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for extension in this context",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,extension);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return extension;
+
+ //Content: 1.annotation?, 2.(attribute | attributeGroup)*, 3.anyAttribute?
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleContentExtension.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ extension.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "attribute")
+ {
+ level = 2;
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ extension.Attributes.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ level = 2;
+ XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h);
+ if(attr != null)
+ extension.attributes.Add(attr);
+ continue;
+ }
+ }
+ if(level <= 3 && reader.LocalName == "anyAttribute")
+ {
+ level = 4;
+ XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h);
+ if(anyattr != null)
+ extension.AnyAttribute = anyattr;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return extension;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs
new file mode 100755
index 00000000000..f908b8788ed
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs
@@ -0,0 +1,337 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleContentRestriction.
+ /// </summary>
+ public class XmlSchemaSimpleContentRestriction : XmlSchemaContent
+ {
+
+ private XmlSchemaAnyAttribute any;
+ private XmlSchemaObjectCollection attributes;
+ private XmlSchemaSimpleType baseType;
+ private XmlQualifiedName baseTypeName;
+ private XmlSchemaObjectCollection facets;
+ private static string xmlname = "restriction";
+
+ public XmlSchemaSimpleContentRestriction()
+ {
+ baseTypeName = XmlQualifiedName.Empty;
+ attributes = new XmlSchemaObjectCollection();
+ facets = new XmlSchemaObjectCollection();
+ }
+
+ [System.Xml.Serialization.XmlAttribute("base")]
+ public XmlQualifiedName BaseTypeName
+ {
+ get{ return baseTypeName; }
+ set{ baseTypeName = value; }
+ }
+
+ [XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaSimpleType BaseType
+ {
+ get{ return baseType; }
+ set{ baseType = value; }
+ }
+
+ [XmlElement("minExclusive",typeof(XmlSchemaMinExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("minInclusive",typeof(XmlSchemaMinInclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("maxExclusive",typeof(XmlSchemaMaxExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("maxInclusive",typeof(XmlSchemaMaxInclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("totalDigits",typeof(XmlSchemaTotalDigitsFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("fractionDigits",typeof(XmlSchemaFractionDigitsFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("length",typeof(XmlSchemaLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("minLength",typeof(XmlSchemaMinLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("maxLength",typeof(XmlSchemaMaxLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("enumeration",typeof(XmlSchemaEnumerationFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("whiteSpace",typeof(XmlSchemaWhiteSpaceFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("pattern",typeof(XmlSchemaPatternFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Facets
+ {
+ get{ return facets; }
+ }
+
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Attributes
+ {
+ get{ return attributes; }
+ }
+
+ [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnyAttribute AnyAttribute
+ {
+ get{ return any; }
+ set{ any = value; }
+ }
+
+ ///<remarks>
+ /// 1. Base must be present and a QName
+ ///</remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(BaseTypeName == null || BaseTypeName.IsEmpty)
+ {
+ error(h, "base must be present and a QName");
+ }
+ else if(!XmlSchemaUtil.CheckQName(BaseTypeName))
+ error(h,"BaseTypeName must be a QName");
+
+ if(BaseType != null)
+ {
+ errorCount += BaseType.Compile(h,info);
+ }
+
+ if(this.AnyAttribute != null)
+ {
+ errorCount += AnyAttribute.Compile(h,info);
+ }
+
+ foreach(XmlSchemaObject obj in Attributes)
+ {
+ if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ errorCount += attr.Compile(h,info);
+ }
+ else if(obj is XmlSchemaAttributeGroupRef)
+ {
+ XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;
+ errorCount += atgrp.Compile(h,info);
+ }
+ else
+ error(h,obj.GetType() +" is not valid in this place::SimpleContentRestriction");
+ }
+
+ //TODO: Compile Facets: Looks like they are a part of datatypes. So we'll do them with the datatypes
+
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<restriction
+ //base = QName
+ //id = ID
+ //{any attributes with non-schema namespace . . .}>
+ //Content: (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern)*)?, ((attribute | attributeGroup)*, anyAttribute?))
+ //</restriction>
+ internal static XmlSchemaSimpleContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleContentRestriction restriction = new XmlSchemaSimpleContentRestriction();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexContentRestriction.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ restriction.LineNumber = reader.LineNumber;
+ restriction.LinePosition = reader.LinePosition;
+ restriction.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "base")
+ {
+ Exception innerex;
+ restriction.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for base attribute",innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ restriction.Id = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for restriction",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,restriction);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return restriction;
+
+ //Content: 1.annotation?,
+ // 2.simpleType?,
+ // 3.(minExclusive |...| enumeration | whiteSpace | pattern)*,
+ // 4.(attribute | attributeGroup)*,
+ // 5.anyAttribute?
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleContentRestriction.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ restriction.Annotation = annotation;
+ continue;
+ }
+ if(level <=2 && reader.LocalName == "simpleType")
+ {
+ level = 3;
+ XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h);
+ if(stype != null)
+ restriction.baseType = stype;
+ continue;
+ }
+ if(level <= 3)
+ {
+ if(reader.LocalName == "minExclusive")
+ {
+ level = 3;
+ XmlSchemaMinExclusiveFacet minex = XmlSchemaMinExclusiveFacet.Read(reader,h);
+ if(minex != null)
+ restriction.facets.Add(minex);
+ continue;
+ }
+ else if(reader.LocalName == "minInclusive")
+ {
+ level = 3;
+ XmlSchemaMinInclusiveFacet mini = XmlSchemaMinInclusiveFacet.Read(reader,h);
+ if(mini != null)
+ restriction.facets.Add(mini);
+ continue;
+ }
+ else if(reader.LocalName == "maxExclusive")
+ {
+ level = 3;
+ XmlSchemaMaxExclusiveFacet maxex = XmlSchemaMaxExclusiveFacet.Read(reader,h);
+ if(maxex != null)
+ restriction.facets.Add(maxex);
+ continue;
+ }
+ else if(reader.LocalName == "maxInclusive")
+ {
+ level = 3;
+ XmlSchemaMaxInclusiveFacet maxi = XmlSchemaMaxInclusiveFacet.Read(reader,h);
+ if(maxi != null)
+ restriction.facets.Add(maxi);
+ continue;
+ }
+ else if(reader.LocalName == "totalDigits")
+ {
+ level = 3;
+ XmlSchemaTotalDigitsFacet total = XmlSchemaTotalDigitsFacet.Read(reader,h);
+ if(total != null)
+ restriction.facets.Add(total);
+ continue;
+ }
+ else if(reader.LocalName == "fractionDigits")
+ {
+ level = 3;
+ XmlSchemaFractionDigitsFacet fraction = XmlSchemaFractionDigitsFacet.Read(reader,h);
+ if(fraction != null)
+ restriction.facets.Add(fraction);
+ continue;
+ }
+ else if(reader.LocalName == "length")
+ {
+ level = 3;
+ XmlSchemaLengthFacet length = XmlSchemaLengthFacet.Read(reader,h);
+ if(length != null)
+ restriction.facets.Add(length);
+ continue;
+ }
+ else if(reader.LocalName == "minLength")
+ {
+ level = 3;
+ XmlSchemaMinLengthFacet minlen = XmlSchemaMinLengthFacet.Read(reader,h);
+ if(minlen != null)
+ restriction.facets.Add(minlen);
+ continue;
+ }
+ else if(reader.LocalName == "maxLength")
+ {
+ level = 3;
+ XmlSchemaMaxLengthFacet maxlen = XmlSchemaMaxLengthFacet.Read(reader,h);
+ if(maxlen != null)
+ restriction.facets.Add(maxlen);
+ continue;
+ }
+ else if(reader.LocalName == "enumeration")
+ {
+ level = 3;
+ XmlSchemaEnumerationFacet enumeration = XmlSchemaEnumerationFacet.Read(reader,h);
+ if(enumeration != null)
+ restriction.facets.Add(enumeration);
+ continue;
+ }
+ else if(reader.LocalName == "whiteSpace")
+ {
+ level = 3;
+ XmlSchemaWhiteSpaceFacet ws = XmlSchemaWhiteSpaceFacet.Read(reader,h);
+ if(ws != null)
+ restriction.facets.Add(ws);
+ continue;
+ }
+ else if(reader.LocalName == "pattern")
+ {
+ level = 3;
+ XmlSchemaPatternFacet pattern = XmlSchemaPatternFacet.Read(reader,h);
+ if(pattern != null)
+ restriction.facets.Add(pattern);
+ continue;
+ }
+ }
+ if(level <= 4)
+ {
+ if(reader.LocalName == "attribute")
+ {
+ level = 4;
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ restriction.Attributes.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ level = 4;
+ XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h);
+ if(attr != null)
+ restriction.attributes.Add(attr);
+ continue;
+ }
+ }
+ if(level <= 5 && reader.LocalName == "anyAttribute")
+ {
+ level = 6;
+ XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h);
+ if(anyattr != null)
+ restriction.AnyAttribute = anyattr;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return restriction;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleType.cs
new file mode 100755
index 00000000000..81007f59a63
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleType.cs
@@ -0,0 +1,237 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleType.
+ /// </summary>
+ public class XmlSchemaSimpleType : XmlSchemaType
+ {
+ private XmlSchemaSimpleTypeContent content;
+ //compilation vars
+ internal bool islocal = true; // Assuming local means we have to specify islocal=false only in XmlSchema
+ private static string xmlname = "simpleType";
+
+ public XmlSchemaSimpleType()
+ {
+ }
+
+ [XmlElement("restriction",typeof(XmlSchemaSimpleTypeRestriction),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("list",typeof(XmlSchemaSimpleTypeList),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("union",typeof(XmlSchemaSimpleTypeUnion),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaSimpleTypeContent Content
+ {
+ get{ return content; }
+ set{ content = value; }
+ }
+
+ /// <remarks>
+ /// For a simple Type:
+ /// 1. Content must be present
+ /// 2. id if present, must have be a valid ID
+ /// a) If the simpletype is local
+ /// 1- are from <xs:complexType name="simpleType"> and <xs:complexType name="localSimpleType">
+ /// 1. name is prohibited
+ /// 2. final is prohibited
+ /// b) If the simpletype is toplevel
+ /// 1- are from <xs:complexType name="simpleType"> and <xs:complexType name="topLevelSimpleType">
+ /// 1. name is required, type must be NCName
+ /// 2. Content is required
+ /// 3. final can have values : #all | (list | union | restriction)
+ /// 4. If final is set, finalResolved is same as final (but within the values of b.3)
+ /// 5. If final is not set, the finalDefault of the schema (ie. only #all and restriction)
+ /// 6. Base type is:
+ /// 4.1 If restriction is chosen,the base type of restriction or elements
+ /// 4.2 otherwise simple ur-type
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ if(this.islocal) // a
+ {
+ if(this.Name != null) // a.1
+ error(h,"Name is prohibited in a local simpletype");
+ if(this.Final != XmlSchemaDerivationMethod.None) //a.2
+ error(h,"Final is prohibited in a local simpletype");
+ }
+ else //b
+ {
+ if(this.Name == null) //b.1
+ error(h,"Name is required in top level simpletype");
+ else if(!XmlSchemaUtil.CheckNCName(this.Name)) // b.1.2
+ error(h,"name attribute of a simpleType must be NCName");
+ else
+ this.qName = new XmlQualifiedName(this.Name,info.TargetNamespace);
+
+ //NOTE: Although the FinalResolved can be Empty, it is not a valid value for Final
+ //DEVIATION: If an error occurs, the finaldefault is always consulted. This deviates
+ // from the way MS implementation works.
+ switch(this.Final) //b.3, b.4
+ {
+ case XmlSchemaDerivationMethod.All:
+ this.finalResolved = XmlSchemaDerivationMethod.All;
+ break;
+ case XmlSchemaDerivationMethod.List:
+ this.finalResolved = XmlSchemaDerivationMethod.List;
+ break;
+ case XmlSchemaDerivationMethod.Union:
+ this.finalResolved = XmlSchemaDerivationMethod.Union;
+ break;
+ case XmlSchemaDerivationMethod.Restriction:
+ this.finalResolved = XmlSchemaDerivationMethod.Restriction;
+ break;
+ default:
+ error(h,"The value of final attribute is not valid for simpleType");
+ goto case XmlSchemaDerivationMethod.None;
+ // use assignment from finaldefault on schema.
+ case XmlSchemaDerivationMethod.None: // b.5
+ if(info.FinalDefault == XmlSchemaDerivationMethod.All)
+ finalResolved = XmlSchemaDerivationMethod.All;
+ else
+ finalResolved = info.FinalDefault & (XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.List |
+ XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Union );
+ break;
+ }
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ if(this.Content == null) //a.3,b.2
+ error(h,"Content is required in a simpletype");
+ else if(Content is XmlSchemaSimpleTypeRestriction)
+ {
+ errorCount += ((XmlSchemaSimpleTypeRestriction)Content).Compile(h,info);
+ }
+ else if(Content is XmlSchemaSimpleTypeList)
+ {
+ errorCount += ((XmlSchemaSimpleTypeList)Content).Compile(h,info);
+ }
+ else if(Content is XmlSchemaSimpleTypeUnion)
+ {
+ errorCount += ((XmlSchemaSimpleTypeUnion)Content).Compile(h,info);
+ }
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(isCompiled)
+ return errorCount;
+
+ return errorCount;
+ }
+
+ //<simpleType
+ // final = (#all | (list | union | restriction))
+ // id = ID
+ // name = NCName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (restriction | list | union))
+ //</simpleType>
+ internal static XmlSchemaSimpleType Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleType stype = new XmlSchemaSimpleType();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaGroup.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ stype.LineNumber = reader.LineNumber;
+ stype.LinePosition = reader.LinePosition;
+ stype.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "final")
+ {
+ Exception innerex;
+ stype.Final = XmlSchemaUtil.ReadDerivationAttribute(reader, out innerex, "final");
+ if(innerex != null)
+ error(h, "some invalid values not a valid value for final", innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ stype.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ stype.Name = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for simpleType",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,stype);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return stype;
+
+ // Content: (annotation?, (restriction | list | union))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleType.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ stype.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "restriction")
+ {
+ level = 3;
+ XmlSchemaSimpleTypeRestriction restriction = XmlSchemaSimpleTypeRestriction.Read(reader,h);
+ if(restriction != null)
+ stype.content = restriction;
+ continue;
+ }
+ if(reader.LocalName == "list")
+ {
+ level = 3;
+ XmlSchemaSimpleTypeList list = XmlSchemaSimpleTypeList.Read(reader,h);
+ if(list != null)
+ stype.content = list;
+ continue;
+ }
+ if(reader.LocalName == "union")
+ {
+ level = 3;
+ XmlSchemaSimpleTypeUnion union = XmlSchemaSimpleTypeUnion.Read(reader,h);
+ if(union != null)
+ stype.content = union;
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return stype;
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeContent.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeContent.cs
new file mode 100755
index 00000000000..6068361768c
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeContent.cs
@@ -0,0 +1,17 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleTypeContent.
+ /// </summary>
+ public abstract class XmlSchemaSimpleTypeContent : XmlSchemaAnnotated
+ {
+ protected XmlSchemaSimpleTypeContent()
+ {
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeList.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeList.cs
new file mode 100755
index 00000000000..dea8741a540
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeList.cs
@@ -0,0 +1,152 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleTypeList.
+ /// </summary>
+ public class XmlSchemaSimpleTypeList : XmlSchemaSimpleTypeContent
+ {
+ private XmlSchemaSimpleType itemType;
+ private XmlQualifiedName itemTypeName;
+ private static string xmlname = "list";
+
+ public XmlSchemaSimpleTypeList()
+ {
+ this.ItemTypeName = XmlQualifiedName.Empty;
+ }
+
+ [System.Xml.Serialization.XmlAttribute("itemType")]
+ public XmlQualifiedName ItemTypeName
+ {
+ get{ return itemTypeName; }
+ set
+ {
+ itemTypeName = value;
+ }
+ }
+
+ [XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaSimpleType ItemType
+ {
+ get{ return itemType; }
+ set
+ {
+ itemType = value;
+ }
+ }
+ /// <remarks>
+ /// 1. One of itemType or a <simpleType> must be present, but not both.
+ /// 2. id must be of type ID
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ if(ItemType != null && !ItemTypeName.IsEmpty)
+ error(h, "both itemType and simpletype can't be present");
+ if(ItemType == null && ItemTypeName.IsEmpty)
+ error(h, "one of itemType or simpletype must be present");
+ if(ItemType != null)
+ {
+ errorCount += ItemType.Compile(h,info);
+ }
+ if(!XmlSchemaUtil.CheckQName(ItemTypeName))
+ error(h,"BaseTypeName must be a XmlQualifiedName");
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<list
+ // id = ID
+ // itemType = QName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (simpleType?))
+ //</list>
+ internal static XmlSchemaSimpleTypeList Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleTypeList list = new XmlSchemaSimpleTypeList();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaSimpleTypeList.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ list.LineNumber = reader.LineNumber;
+ list.LinePosition = reader.LinePosition;
+ list.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ list.Id = reader.Value;
+ }
+ else if(reader.Name == "itemType")
+ {
+ Exception innerex;
+ list.ItemTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for itemType attribute",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for list",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,list);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return list;
+ // Content: annotation?, simpleType?
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleTypeList.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ list.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2 && reader.LocalName == "simpleType")
+ {
+ level = 3;
+ XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h);
+ if(stype != null)
+ list.itemType = stype;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return list;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs
new file mode 100755
index 00000000000..b3f78b77129
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs
@@ -0,0 +1,267 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleTypeRestriction.
+ /// </summary>
+ public class XmlSchemaSimpleTypeRestriction : XmlSchemaSimpleTypeContent
+ {
+ private XmlSchemaSimpleType baseType;
+ private XmlQualifiedName baseTypeName;
+ private XmlSchemaObjectCollection facets;
+ private static string xmlname = "restriction";
+
+ public XmlSchemaSimpleTypeRestriction()
+ {
+ baseTypeName = XmlQualifiedName.Empty;
+ facets = new XmlSchemaObjectCollection();
+ }
+
+ [System.Xml.Serialization.XmlAttribute("base")]
+ public XmlQualifiedName BaseTypeName
+ {
+ get{ return baseTypeName; }
+ set{ baseTypeName = value; }
+ }
+
+ [XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaSimpleType BaseType
+ {
+ get{ return baseType; }
+ set{ baseType = value; }
+ }
+
+ [XmlElement("minExclusive",typeof(XmlSchemaMinExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("minInclusive",typeof(XmlSchemaMinInclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("maxExclusive",typeof(XmlSchemaMaxExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("maxInclusive",typeof(XmlSchemaMaxInclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("totalDigits",typeof(XmlSchemaTotalDigitsFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("fractionDigits",typeof(XmlSchemaFractionDigitsFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("length",typeof(XmlSchemaLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("minLength",typeof(XmlSchemaMinLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("maxLength",typeof(XmlSchemaMaxLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("enumeration",typeof(XmlSchemaEnumerationFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("whiteSpace",typeof(XmlSchemaWhiteSpaceFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("pattern",typeof(XmlSchemaPatternFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Facets
+ {
+ get{ return facets; }
+ }
+
+ /// <remarks>
+ /// 1. One of base or simpletype must be present but not both
+ /// 2. id must be a valid ID
+ /// 3. base must be a valid QName *NO CHECK REQUIRED*
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ if(this.baseType != null && !this.BaseTypeName.IsEmpty)
+ error(h, "both base and simpletype can't be set");
+ if(this.baseType == null && this.BaseTypeName.IsEmpty)
+ error(h, "one of basetype or simpletype must be present");
+ if(this.baseType != null)
+ {
+ errorCount += this.baseType.Compile(h,info);
+ }
+ if(!XmlSchemaUtil.CheckQName(BaseTypeName))
+ error(h,"BaseTypeName must be a XmlQualifiedName");
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<restriction
+ // base = QName
+ // id = ID
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern)*))
+ //</restriction>
+ internal static XmlSchemaSimpleTypeRestriction Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaSimpleTypeRestriction.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ restriction.LineNumber = reader.LineNumber;
+ restriction.LinePosition = reader.LinePosition;
+ restriction.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ restriction.Id = reader.Value;
+ }
+ else if(reader.Name == "base")
+ {
+ Exception innerex;
+ restriction.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for base attribute",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for restriction",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,restriction);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return restriction;
+
+ // Content: annotation?, simpleType?, (minExclusive |. .. | pattern)*
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleTypeRestriction.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ restriction.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2 && reader.LocalName == "simpleType")
+ {
+ level = 3;
+ XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h);
+ if(stype != null)
+ restriction.baseType = stype;
+ continue;
+ }
+ if(level <= 3)
+ {
+ if(reader.LocalName == "minExclusive")
+ {
+ level = 3;
+ XmlSchemaMinExclusiveFacet minex = XmlSchemaMinExclusiveFacet.Read(reader,h);
+ if(minex != null)
+ restriction.facets.Add(minex);
+ continue;
+ }
+ else if(reader.LocalName == "minInclusive")
+ {
+ level = 3;
+ XmlSchemaMinInclusiveFacet mini = XmlSchemaMinInclusiveFacet.Read(reader,h);
+ if(mini != null)
+ restriction.facets.Add(mini);
+ continue;
+ }
+ else if(reader.LocalName == "maxExclusive")
+ {
+ level = 3;
+ XmlSchemaMaxExclusiveFacet maxex = XmlSchemaMaxExclusiveFacet.Read(reader,h);
+ if(maxex != null)
+ restriction.facets.Add(maxex);
+ continue;
+ }
+ else if(reader.LocalName == "maxInclusive")
+ {
+ level = 3;
+ XmlSchemaMaxInclusiveFacet maxi = XmlSchemaMaxInclusiveFacet.Read(reader,h);
+ if(maxi != null)
+ restriction.facets.Add(maxi);
+ continue;
+ }
+ else if(reader.LocalName == "totalDigits")
+ {
+ level = 3;
+ XmlSchemaTotalDigitsFacet total = XmlSchemaTotalDigitsFacet.Read(reader,h);
+ if(total != null)
+ restriction.facets.Add(total);
+ continue;
+ }
+ else if(reader.LocalName == "fractionDigits")
+ {
+ level = 3;
+ XmlSchemaFractionDigitsFacet fraction = XmlSchemaFractionDigitsFacet.Read(reader,h);
+ if(fraction != null)
+ restriction.facets.Add(fraction);
+ continue;
+ }
+ else if(reader.LocalName == "length")
+ {
+ level = 3;
+ XmlSchemaLengthFacet length = XmlSchemaLengthFacet.Read(reader,h);
+ if(length != null)
+ restriction.facets.Add(length);
+ continue;
+ }
+ else if(reader.LocalName == "minLength")
+ {
+ level = 3;
+ XmlSchemaMinLengthFacet minlen = XmlSchemaMinLengthFacet.Read(reader,h);
+ if(minlen != null)
+ restriction.facets.Add(minlen);
+ continue;
+ }
+ else if(reader.LocalName == "maxLength")
+ {
+ level = 3;
+ XmlSchemaMaxLengthFacet maxlen = XmlSchemaMaxLengthFacet.Read(reader,h);
+ if(maxlen != null)
+ restriction.facets.Add(maxlen);
+ continue;
+ }
+ else if(reader.LocalName == "enumeration")
+ {
+ level = 3;
+ XmlSchemaEnumerationFacet enumeration = XmlSchemaEnumerationFacet.Read(reader,h);
+ if(enumeration != null)
+ restriction.facets.Add(enumeration);
+ continue;
+ }
+ else if(reader.LocalName == "whiteSpace")
+ {
+ level = 3;
+ XmlSchemaWhiteSpaceFacet ws = XmlSchemaWhiteSpaceFacet.Read(reader,h);
+ if(ws != null)
+ restriction.facets.Add(ws);
+ continue;
+ }
+ else if(reader.LocalName == "pattern")
+ {
+ level = 3;
+ XmlSchemaPatternFacet pattern = XmlSchemaPatternFacet.Read(reader,h);
+ if(pattern != null)
+ restriction.facets.Add(pattern);
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return restriction;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeUnion.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeUnion.cs
new file mode 100755
index 00000000000..f6279ad6bf3
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeUnion.cs
@@ -0,0 +1,175 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleTypeUnion.
+ /// </summary>
+ public class XmlSchemaSimpleTypeUnion : XmlSchemaSimpleTypeContent
+ {
+ private XmlSchemaObjectCollection baseTypes;
+ private XmlQualifiedName[] memberTypes;
+ private static string xmlname = "union";
+
+ public XmlSchemaSimpleTypeUnion()
+ {
+ baseTypes = new XmlSchemaObjectCollection();
+ }
+
+ [XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection BaseTypes
+ {
+ get{ return baseTypes; }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("memberTypes")]
+ public XmlQualifiedName[] MemberTypes
+ {
+ get{ return memberTypes; }
+ set{ memberTypes = value; }
+ }
+ /// <remarks>
+ /// 1. Circular union type definition is disallowed. (WTH is this?)
+ /// 2. id must be a valid ID
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ int count = BaseTypes.Count;
+
+ foreach(XmlSchemaObject obj in baseTypes)
+ {
+ if(obj != null && obj is XmlSchemaSimpleType)
+ {
+ XmlSchemaSimpleType stype = (XmlSchemaSimpleType) obj;
+ errorCount += stype.Compile(h,info);
+ }
+ else
+ {
+ error(h, "baseTypes can't have objects other than a simpletype");
+ }
+ }
+
+ if(memberTypes!=null)
+ {
+ for(int i=0; i< memberTypes.Length; i++)
+ {
+ if(memberTypes[i] == null || !XmlSchemaUtil.CheckQName(MemberTypes[i]))
+ {
+ warn(h,"Invalid membertype");
+ memberTypes[i] = XmlQualifiedName.Empty;
+ }
+ else
+ {
+ count += MemberTypes.Length;
+ }
+ }
+ }
+
+ if(count == 0)
+ error(h, "Atleast one simpletype or membertype must be present");
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<union
+ // id = ID
+ // memberTypes = List of QName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (simpleType*))
+ //</union>
+ internal static XmlSchemaSimpleTypeUnion Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleTypeUnion union = new XmlSchemaSimpleTypeUnion();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaSimpleTypeUnion.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ union.LineNumber = reader.LineNumber;
+ union.LinePosition = reader.LinePosition;
+ union.SourceUri = reader.BaseURI;
+
+ //Read Attributes
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ union.Id = reader.Value;
+ }
+ else if(reader.Name == "memberTypes")
+ {
+ Exception innerEx;
+ string[] names = XmlSchemaUtil.SplitList(reader.Value);
+ union.memberTypes = new XmlQualifiedName[names.Length];
+ for(int i=0;i<names.Length;i++)
+ {
+ union.memberTypes[i] = XmlSchemaUtil.ToQName(reader,names[i],out innerEx);
+ if(innerEx != null)
+ error(h,"'"+names[i] + "' is not a valid memberType",innerEx);
+ }
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for union",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,union);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return union;
+
+ // Content: annotation?, simpleType*
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleTypeUnion.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ union.Annotation = annotation;
+ continue;
+ }
+ if(level <=2 && reader.LocalName == "simpleType")
+ {
+ level = 2;
+ XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h);
+ if(stype != null)
+ union.baseTypes.Add(stype);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return union;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaTotalDigitsFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaTotalDigitsFacet.cs
new file mode 100755
index 00000000000..d7ef688b549
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaTotalDigitsFacet.cs
@@ -0,0 +1,96 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaTotalDigitsFacet.
+ /// </summary>
+ public class XmlSchemaTotalDigitsFacet : XmlSchemaNumericFacet
+ {
+ private static string xmlname = "totalDigits";
+
+ public XmlSchemaTotalDigitsFacet()
+ {
+ }
+ //<totalDigits
+ // fixed = boolean : false
+ // id = ID
+ // value = positiveInteger
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</totalDigits>
+ internal static XmlSchemaTotalDigitsFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaTotalDigitsFacet td = new XmlSchemaTotalDigitsFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaTotalDigitsFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ td.LineNumber = reader.LineNumber;
+ td.LinePosition = reader.LinePosition;
+ td.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ td.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ td.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ td.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,td);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return td;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaTotalDigitsFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ td.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return td;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs
new file mode 100755
index 00000000000..e1a24b97c17
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs
@@ -0,0 +1,81 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.ComponentModel;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaType.
+ /// </summary>
+ public class XmlSchemaType : XmlSchemaAnnotated
+ {
+ private object baseSchemaType;
+ private XmlSchemaDatatype datatype;
+ private XmlSchemaDerivationMethod derivedBy;
+ private XmlSchemaDerivationMethod final;
+ internal XmlSchemaDerivationMethod finalResolved;
+ private bool isMixed;
+ private string name;
+ internal XmlQualifiedName qName;
+
+ public XmlSchemaType()
+ {
+ final = XmlSchemaDerivationMethod.None;
+ qName = XmlQualifiedName.Empty;
+ }
+
+ #region Attributes
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name; }
+ set{ name = value; }
+ }
+ [DefaultValue(XmlSchemaDerivationMethod.None)]
+ [System.Xml.Serialization.XmlAttribute("final")]
+ public XmlSchemaDerivationMethod Final
+ {
+ get{ return final; }
+ set{ final = value; }
+ }
+ [XmlIgnore]
+ public XmlQualifiedName QualifiedName
+ {
+ get{ return qName; }
+ }
+ [XmlIgnore]
+ public XmlSchemaDerivationMethod FinalResolved
+ {
+ get{ return finalResolved; }
+ }
+ [XmlIgnore]
+ public object BaseSchemaType
+ {
+ get{ return baseSchemaType; }
+ }
+ [XmlIgnore]
+ public XmlSchemaDerivationMethod DerivedBy
+ {
+ get{ return derivedBy; }
+ }
+ [XmlIgnore]
+ public XmlSchemaDatatype Datatype
+ {
+ get{ return datatype; }
+ }
+ #endregion
+
+ #region XmlIgnore
+ [XmlIgnore]
+ public virtual bool IsMixed
+ {
+ get{ return isMixed; }
+ set{ isMixed = value; }
+ }
+ #endregion
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs
new file mode 100755
index 00000000000..bb8fd7a6e0d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs
@@ -0,0 +1,126 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaUnique.
+ /// </summary>
+ public class XmlSchemaUnique : XmlSchemaIdentityConstraint
+ {
+ private static string xmlname = "unique";
+
+ public XmlSchemaUnique()
+ {
+ }
+ /// <remarks>
+ /// 1. name must be present
+ /// 2. selector and field must be present
+ /// </remarks>
+ [MonoTODO]
+ internal new int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ return base.Compile(h,info);
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ internal new void error(ValidationEventHandler handle, string message)
+ {
+ errorCount++;
+ ValidationHandler.RaiseValidationError(handle, this, message);
+ }
+ //<unique
+ // id = ID
+ // name = NCName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (selector, field+))
+ //</unique>
+ internal static XmlSchemaUnique Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaUnique unique = new XmlSchemaUnique();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaUnique.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ unique.LineNumber = reader.LineNumber;
+ unique.LinePosition = reader.LinePosition;
+ unique.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ unique.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ unique.Name = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for unique",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,unique);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return unique;
+
+ // Content: annotation?, selector, field+
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaUnion.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ unique.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2 && reader.LocalName == "selector")
+ {
+ level = 3;
+ XmlSchemaXPath selector = XmlSchemaXPath.Read(reader,h,"selector");
+ if(selector != null)
+ unique.Selector = selector;
+ continue;
+ }
+ if(level <= 3 && reader.LocalName == "field")
+ {
+ level = 3;
+ if(unique.Selector == null)
+ error(h,"selector must be defined before field declarations",null);
+ XmlSchemaXPath field = XmlSchemaXPath.Read(reader,h,"field");
+ if(field != null)
+ unique.Fields.Add(field);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return unique;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUse.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUse.cs
new file mode 100755
index 00000000000..8015edd8ed2
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUse.cs
@@ -0,0 +1,22 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaUse.
+ /// </summary>
+ public enum XmlSchemaUse
+ {
+ [XmlIgnore]
+ None = 0x00000000,
+ [XmlEnum("optional")]
+ Optional = 0x00000001,
+ [XmlEnum("prohibited")]
+ Prohibited = 0x00000002,
+ [XmlEnum("required")]
+ Required = 0x00000003,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUtil.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUtil.cs
new file mode 100755
index 00000000000..dc6a7c6a64d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUtil.cs
@@ -0,0 +1,299 @@
+using System;
+using System.Xml;
+using System.Collections;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// All Methods in this class should use XmlConvert. Some Methods are not present in the
+ /// MS Implementation. We should provide them.
+ /// </summary>
+ internal class XmlSchemaUtil
+ {
+ private XmlSchemaUtil()
+ {}
+
+ public static void CompileID(string id, XmlSchemaObject xso, Hashtable idCollection, ValidationEventHandler h)
+ {
+ //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#ID
+ // 1. ID must be a NCName
+ // 2. ID must be unique in the schema
+ if(id == null)
+ return;
+ if(!CheckNCName(id))
+ xso.error(h,id+" is not a valid id attribute");
+ else if(idCollection.ContainsKey(id))
+ xso.error(h,"Duplicate id attribute "+id);
+ else
+ idCollection.Add(id,xso);
+ }
+
+ [MonoTODO]
+ public static bool CheckAnyUri(string uri)
+ {
+ return true;
+ }
+
+ public static bool CheckToken(string token)
+ {
+ //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#token
+ return true;
+ }
+
+ public static bool CheckNormalizedString(string token)
+ {
+ return true;
+ }
+
+ public static bool CheckLanguage(string lang)
+ {
+ //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#language
+ return true;
+ }
+ public static bool CheckNCName(string name)
+ {
+ //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#NCName
+ try
+ {
+ XmlConvert.VerifyNCName(name);
+ return true;
+ }
+ catch(Exception ex)
+ {
+ return false;
+ }
+ }
+
+ public static bool CheckQName(XmlQualifiedName qname)
+ {
+ return true;
+ }
+ public static bool IsValidQName(string qname)
+ {
+ foreach(string part in qname.Split(new char[]{':'},2))
+ {
+ if(!CheckNCName(part))
+ return false;
+ }
+ return true;
+ }
+
+ //FIXME: First remove all the multiple instances of whitespace and then return the strings.
+ //The current method returns empty strings if there are two or more consecutive whitespaces.
+ public static string[] SplitList(string list)
+ {
+ if(list == null || list == string.Empty)
+ return new String[0];
+
+ string[] listarr = list.Split(new char[]{' ','\t','\n'});
+ int pos=0;
+ int i = 0;
+ for(i=0;i<listarr.Length;i++)
+ {
+ if(listarr[i] != null && listarr[i] != String.Empty)
+ {
+ listarr[pos++] = listarr[i];
+ }
+ }
+ if(pos == i)
+ return listarr;
+ string[] retarr = new String[pos];
+ if(pos!=0)
+ Array.Copy(listarr, retarr, pos);
+ return retarr;
+ }
+
+ public static void ReadUnhandledAttribute(XmlReader reader, XmlSchemaObject xso)
+ {
+ if(reader.Prefix == "xmlns")
+ xso.Namespaces.Add(reader.LocalName, reader.Value);
+ else if(reader.Name == "xmlns")
+ xso.Namespaces.Add("",reader.Value);
+ else
+ {
+ if(xso.unhandledAttributeList == null)
+ xso.unhandledAttributeList = new System.Collections.ArrayList();
+ XmlAttribute attr = new XmlDocument().CreateAttribute(reader.LocalName,reader.NamespaceURI);
+ attr.Value = reader.Value;
+ xso.unhandledAttributeList.Add(attr);
+ }
+ }
+
+ public static bool ReadBoolAttribute(XmlReader reader, out Exception innerExcpetion)
+ {
+ innerExcpetion = null;
+ try
+ {
+ bool val = XmlConvert.ToBoolean(reader.Value);
+ return val;
+ }
+ catch(Exception ex)
+ {
+ innerExcpetion = ex;
+ return false;
+ }
+ }
+ public static decimal ReadDecimalAttribute(XmlReader reader, out Exception innerExcpetion)
+ {
+ innerExcpetion = null;
+ try
+ {
+ decimal val = XmlConvert.ToDecimal(reader.Value);
+ return val;
+ }
+ catch(Exception ex)
+ {
+ innerExcpetion = ex;
+ return decimal.Zero;
+ }
+ }
+
+ // Is some value is read, return it.
+ // If no values return empty.
+ // If exception, return none
+ public static XmlSchemaDerivationMethod ReadDerivationAttribute(XmlReader reader, out Exception innerExcpetion, string name)
+ {
+ innerExcpetion = null;
+ try
+ {
+ string list = reader.Value;
+ string warn = "";
+ XmlSchemaDerivationMethod val = 0;
+
+ if(list.IndexOf("#all") != -1 && list.Trim() != "#all")
+ {
+ innerExcpetion = new Exception(list+" is not a valid value for "+ name +". #all if present must be the only value");
+ return XmlSchemaDerivationMethod.All;
+ }
+ foreach(string xsdm in XmlSchemaUtil.SplitList(list))
+ {
+ switch(xsdm)
+ {
+ case "":
+ val |= XmlSchemaDerivationMethod.Empty; break;
+ case "#all":
+ val |= XmlSchemaDerivationMethod.All; break;
+ case "substitution":
+ val |= XmlSchemaDerivationMethod.Substitution; break;
+ case "extension":
+ val |= XmlSchemaDerivationMethod.Extension; break;
+ case "restriction":
+ val |= XmlSchemaDerivationMethod.Restriction; break;
+ case "list":
+ val |= XmlSchemaDerivationMethod.List; break;
+ case "union":
+ val |= XmlSchemaDerivationMethod.Union; break;
+ default:
+ warn += xsdm + " "; break;
+ }
+ }
+ if(warn != "")
+ innerExcpetion = new Exception(warn + "is/are not valid values for " + name);
+ return val;
+ }
+ catch(Exception ex)
+ {
+ innerExcpetion = ex;
+ return XmlSchemaDerivationMethod.None;
+ }
+ }
+
+ public static XmlSchemaForm ReadFormAttribute(XmlReader reader, out Exception innerExcpetion)
+ {
+ innerExcpetion = null;
+ XmlSchemaForm val = XmlSchemaForm.None;
+ switch(reader.Value)
+ {
+ case "qualified":
+ val = XmlSchemaForm.Qualified; break;
+ case "unqualified":
+ val = XmlSchemaForm.Unqualified; break;
+ default:
+ innerExcpetion = new Exception("only qualified or unqulified is a valid value"); break;
+ }
+ return val;
+ }
+
+ public static XmlSchemaContentProcessing ReadProcessingAttribute(XmlReader reader, out Exception innerExcpetion)
+ {
+ innerExcpetion = null;
+ XmlSchemaContentProcessing val = XmlSchemaContentProcessing.None;
+ switch(reader.Value)
+ {
+ case "lax":
+ val = XmlSchemaContentProcessing.Lax; break;
+ case "strict":
+ val = XmlSchemaContentProcessing.Strict; break;
+ case "skip":
+ val = XmlSchemaContentProcessing.Skip; break;
+ default:
+ innerExcpetion = new Exception("only lax , strict or skip are valid values for processContents");
+ break;
+ }
+ return val;
+ }
+
+ public static XmlSchemaUse ReadUseAttribute(XmlReader reader, out Exception innerExcpetion)
+ {
+ innerExcpetion = null;
+ XmlSchemaUse val = XmlSchemaUse.None;
+ switch(reader.Value)
+ {
+ case "optional":
+ val = XmlSchemaUse.Optional; break;
+ case "prohibited":
+ val = XmlSchemaUse.Prohibited; break;
+ case "required":
+ val = XmlSchemaUse.Required; break;
+ default:
+ innerExcpetion = new Exception("only optional , prohibited or required are valid values for use");
+ break;
+ }
+ return val;
+ }
+ public static XmlQualifiedName ReadQNameAttribute(XmlReader reader, out Exception innerEx)
+ {
+ return ToQName(reader, reader.Value, out innerEx);
+ }
+
+ //While Creating a XmlQualifedName, we should check:
+ // 1. If a prefix is present, its namespace should be resolvable.
+ // 2. If a prefix is not present, and if the defaultNamespace is set,
+ public static XmlQualifiedName ToQName(XmlReader reader, string qnamestr, out Exception innerEx)
+ {
+
+ string ns;
+ string name;
+ XmlQualifiedName qname;
+ innerEx = null;
+
+ if(!IsValidQName(qnamestr))
+ {
+ innerEx = new Exception(qnamestr + " is an invalid QName. Either name or namespace is not a NCName");
+ return XmlQualifiedName.Empty;
+ }
+
+ string[] values = qnamestr.Split(new char[]{':'},2);
+
+ if(values.Length == 2)
+ {
+ ns = reader.LookupNamespace(values[0]);
+ if(ns == null)
+ {
+ innerEx = new Exception("Namespace Prefix '"+values[0]+"could not be resolved");
+ return XmlQualifiedName.Empty;
+ }
+ name = values[1];
+ }
+ else
+ {
+ //Default Namespace
+ ns = reader.LookupNamespace("");
+ name = values[0];
+ }
+
+ qname = new XmlQualifiedName(name,ns);
+ return qname;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.cs
new file mode 100755
index 00000000000..df39caba223
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.cs
@@ -0,0 +1,97 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaWhiteSpaceFacet.
+ /// </summary>
+ public class XmlSchemaWhiteSpaceFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "whiteSpace";
+
+ public XmlSchemaWhiteSpaceFacet()
+ {
+ }
+ // <whiteSpace
+ // fixed = boolean : false
+ // id = ID
+ // value = (collapse | preserve | replace)
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ // </whiteSpace>
+ internal static XmlSchemaWhiteSpaceFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaWhiteSpaceFacet ws = new XmlSchemaWhiteSpaceFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaWhiteSpaceFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ ws.LineNumber = reader.LineNumber;
+ ws.LinePosition = reader.LinePosition;
+ ws.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ ws.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ ws.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ ws.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,ws);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return ws;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaWhiteSpaceFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ ws.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return ws;
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaXPath.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaXPath.cs
new file mode 100755
index 00000000000..8f7447e0f53
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaXPath.cs
@@ -0,0 +1,104 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.ComponentModel;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaXPath.
+ /// </summary>
+ public class XmlSchemaXPath : XmlSchemaAnnotated
+ {
+ private string xpath;
+
+ public XmlSchemaXPath()
+ {
+ }
+ [DefaultValue(null)]
+ [System.Xml.Serialization.XmlAttribute("xpath")]
+ public string XPath
+ {
+ get{ return xpath; }
+ set{ xpath = value; }
+ }
+
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);
+ return errorCount;
+ }
+
+ //<selector
+ // id = ID
+ // xpath = a subset of XPath expression, see below
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</selector>
+ internal static XmlSchemaXPath Read(XmlSchemaReader reader, ValidationEventHandler h,string name)
+ {
+ XmlSchemaXPath path = new XmlSchemaXPath();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != name)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexContentRestriction.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ path.LineNumber = reader.LineNumber;
+ path.LinePosition = reader.LinePosition;
+ path.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ path.Id = reader.Value;
+ }
+ else if(reader.Name == "xpath")
+ {
+ path.xpath = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+name,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,path);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return path;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != name)
+ error(h,"Should not happen :2: XmlSchemaXPath.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ path.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return path;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSeverityType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSeverityType.cs
new file mode 100755
index 00000000000..f16d15967e8
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSeverityType.cs
@@ -0,0 +1,15 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSeverityType.
+ /// </summary>
+ public enum XmlSeverityType
+ {
+ Error = 0x00000000,
+ Warning = 0x00000001,
+ }
+}