| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- // Author: Dwivedi, Ajay kumar
- // [email protected]
- 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 int errorCount;
- public XmlSchemaAttributeGroup()
- {
- attributes = new XmlSchemaObjectCollection();
- }
- [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
- public XmlSchemaAnyAttribute AnyAttribute
- {
- get{ return any;}
- set{ any = 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;}
- }
- [System.Xml.Serialization.XmlAttribute("name")]
- public string Name
- {
- get{ return name;}
- set{ name = 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;
- 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.targetNS);
-
- 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;
- }
-
- internal void error(ValidationEventHandler handle,string message)
- {
- this.errorCount++;
- ValidationHandler.RaiseValidationError(handle,this,message);
- }
- }
- }
|