瀏覽代碼

2003-07-20 Atsushi Enomoto <[email protected]>

	* XmlSchema.cs : added support for collecting missing type references
	  at compilation-time.
	* XmlSchemaType.cs, XmlSchemaComplexType.cs, XmlSchemaSimpleType.cs:
	  - Renamed qName to QNameInternal.
	  - Added BaseSchemaType and ContentTypeParticle support.

svn path=/trunk/mcs/; revision=16437
Atsushi Eno 22 年之前
父節點
當前提交
7fc66b4393

+ 8 - 0
mcs/class/System.XML/System.Xml.Schema/ChangeLog

@@ -1,3 +1,11 @@
+2003-07-20  Atsushi Enomoto  <[email protected]>
+
+	* XmlSchema.cs : added support for collecting missing type references
+	  at compilation-time.
+	* XmlSchemaType.cs, XmlSchemaComplexType.cs, XmlSchemaSimpleType.cs:
+	  - Renamed qName to QNameInternal.
+	  - Added BaseSchemaType and ContentTypeParticle support.
+
 2003-07-19  Atsushi Enomoto  <[email protected]>
 
 	* XmlSchema.cs, XmlSchemaAll.cs, XmlSchemaAnnotated.cs,

+ 8 - 19
mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs

@@ -45,6 +45,7 @@ namespace System.Xml.Schema
 
 		// post schema compilation infoset
 		private Hashtable idCollection;
+		private Hashtable missingBaseSchemaTypeRefs;
 
                 // Compiler specific things
                 private static string xmlname = "schema";
@@ -65,6 +66,7 @@ namespace System.Xml.Schema
                         notations                       = new XmlSchemaObjectTable();
                         schemaTypes                     = new XmlSchemaObjectTable();
 			idCollection                    = new Hashtable ();
+			missingBaseSchemaTypeRefs       = new Hashtable ();
 
                 }
 
@@ -220,28 +222,11 @@ namespace System.Xml.Schema
 			get { return idCollection; }
 		}
 
-		/*
-		internal XmlSchemaForm ElementFormDefaultCompiled
+		internal Hashtable MissingBaseSchemaTypeRefs
 		{
-			get { return elementFormDefaultCompiled; }
+			get { return missingBaseSchemaTypeRefs; }
 		}
 
-		internal XmlSchemaForm AttributeFormDefaultCompiled
-		{
-			get { return attributeFormDefaultCompiled; }
-		}
-
-		internal XmlSchemaDerivationMethod BlockDefaultCompiled
-		{
-			get { return blockDefaultCompiled; }
-		}
-
-		internal XmlSchemaDerivationMethod FinalDefaultCompiled
-		{
-			get { return finalDefaultCompiled; }
-		}
-		*/
-
                 #endregion
 
                 #region Compile
@@ -338,6 +323,10 @@ namespace System.Xml.Schema
                                         }
                                 }
 			}
+			// Add missing references.
+			foreach (XmlSchemaComplexType cType in missingBaseSchemaTypeRefs.Keys)
+				cType.BaseSchemaTypeInternal = 
+					SchemaTypes [missingBaseSchemaTypeRefs [cType] as XmlQualifiedName];
 
 			foreach(XmlSchemaObject obj in Items)
                         {

+ 39 - 1
mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs

@@ -160,6 +160,7 @@ namespace System.Xml.Schema
 			if (this.IsComplied (schema.CompilationId))
 				return 0;
 
+			// block/final resolution
 			if(istoplevel)
 			{
 				if(this.Name == null || this.Name == string.Empty)
@@ -167,7 +168,7 @@ namespace System.Xml.Schema
 				else if(!XmlSchemaUtil.CheckNCName(Name))
 					error(h,"name must be a NCName");
 				else
-					this.qName = new XmlQualifiedName(Name, schema.TargetNamespace);
+					this.QNameInternal = new XmlQualifiedName(Name, schema.TargetNamespace);
 				
 				if(Block != XmlSchemaDerivationMethod.None)
 				{
@@ -234,20 +235,56 @@ namespace System.Xml.Schema
 					error(h,"block must be absent in a local complex type");
 			}
 
+			// Process contents and BaseSchemaType
 			if(ContentModel != null)
 			{
 				if(anyAttribute != null || Attributes.Count != 0 || Particle != null)
 					error(h,"attributes, particles or anyattribute is not allowed if ContentModel is present");
 
+				XmlQualifiedName baseTypeName = null;
 				if(ContentModel is XmlSchemaSimpleContent)
 				{
 					XmlSchemaSimpleContent smodel = (XmlSchemaSimpleContent)ContentModel;
 					errorCount += smodel.Compile(h,schema);
+
+					XmlSchemaSimpleContentExtension sscx = smodel.Content as XmlSchemaSimpleContentExtension;
+					if (sscx != null)
+						baseTypeName = sscx.BaseTypeName;
+					else {
+						XmlSchemaSimpleContentRestriction sscr = smodel.Content as XmlSchemaSimpleContentRestriction;
+						baseTypeName = sscr.BaseTypeName;
+						if (sscr.BaseType != null) {
+							sscr.BaseType.Compile (h, schema);
+							BaseSchemaTypeInternal = sscr.BaseType;
+						}
+					}
 				}
 				else if(ContentModel is XmlSchemaComplexContent)
 				{
 					XmlSchemaComplexContent cmodel = (XmlSchemaComplexContent)ContentModel;
 					errorCount += cmodel.Compile(h,schema);
+
+					XmlSchemaComplexContentExtension sccx = cmodel.Content as XmlSchemaComplexContentExtension;
+					if (sccx != null) {
+						contentTypeParticle = sccx.Particle;
+						baseTypeName = sccx.BaseTypeName;
+					}
+					else {
+						XmlSchemaComplexContentRestriction sccr = cmodel.Content as XmlSchemaComplexContentRestriction;
+						contentTypeParticle = sccr.Particle;
+						baseTypeName = sccr.BaseTypeName;
+					}
+				}
+
+				// fill base schema type
+				if (BaseSchemaTypeInternal == null && baseTypeName != null) {	// simple content restriction may have type itself.
+					if (baseTypeName.Namespace == XmlSchema.Namespace)
+						BaseSchemaTypeInternal = XmlSchemaDatatype.FromName (baseTypeName);
+					else {
+						BaseSchemaTypeInternal = schema.SchemaTypes [baseTypeName];
+						if (BaseSchemaTypeInternal == null)
+							schema.MissingBaseSchemaTypeRefs.Add (this, baseTypeName);
+					}
 				}
 			}
 			else
@@ -272,6 +309,7 @@ namespace System.Xml.Schema
 					XmlSchemaSequence xss = (XmlSchemaSequence)Particle;
 					errorCount += xss.Compile(h,schema);
 				}
+				this.contentTypeParticle = Particle;
 
 				if(this.anyAttribute != null)
 				{

+ 1 - 1
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleType.cs

@@ -71,7 +71,7 @@ namespace System.Xml.Schema
 				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,schema.TargetNamespace);
+					this.QNameInternal = new XmlQualifiedName(this.Name,schema.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

+ 5 - 5
mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs

@@ -12,19 +12,19 @@ namespace System.Xml.Schema
 	/// </summary>
 	public class XmlSchemaType : XmlSchemaAnnotated
 	{
-		private object baseSchemaType;
+		internal object BaseSchemaTypeInternal;
 		private XmlSchemaDatatype datatype;
 		private XmlSchemaDerivationMethod derivedBy;
 		private XmlSchemaDerivationMethod final;
 		internal XmlSchemaDerivationMethod finalResolved;
 		private bool isMixed;
 		private string name;
-		internal XmlQualifiedName qName;
+		internal XmlQualifiedName QNameInternal;
 
 		public XmlSchemaType()
 		{
 			final = XmlSchemaDerivationMethod.None;
-			qName = XmlQualifiedName.Empty;
+			QNameInternal = XmlQualifiedName.Empty;
 		}
 
 		#region Attributes
@@ -44,7 +44,7 @@ namespace System.Xml.Schema
 		[XmlIgnore]
 		public XmlQualifiedName QualifiedName 
 		{
-			get{ return qName; }
+			get{ return QNameInternal; }
 		}
 		[XmlIgnore]
 		public XmlSchemaDerivationMethod FinalResolved 
@@ -54,7 +54,7 @@ namespace System.Xml.Schema
 		[XmlIgnore]
 		public object BaseSchemaType 
 		{
-			get{ return  baseSchemaType; }
+			get{ return  BaseSchemaTypeInternal; }
 		}
 		[XmlIgnore]
 		public XmlSchemaDerivationMethod DerivedBy