| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- // Author: Dwivedi, Ajay kumar
- // [email protected]
- 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 int errorCount = 0;
- public XmlSchemaComplexContentRestriction()
- {
- baseTypeName = XmlQualifiedName.Empty;
- attributes = new XmlSchemaObjectCollection();
- }
- [System.Xml.Serialization.XmlAttribute("base")]
- public XmlQualifiedName BaseTypeName
- {
- get{ return baseTypeName; }
- set{ baseTypeName = value; }
- }
- [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; }
- }
- [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; }
- }
- /// <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");
- }
-
- 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,"object is not valid in this place");
- }
-
- 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);
- }
- }
- if(this.Id != null && !XmlSchemaUtil.CheckID(Id))
- error(h, "id must be a valid ID");
-
- return errorCount;
- }
-
- [MonoTODO]
- internal int Validate(ValidationEventHandler h)
- {
- return errorCount;
- }
- internal void error(ValidationEventHandler handle,string message)
- {
- errorCount++;
- ValidationHandler.RaiseValidationError(handle,this,message);
- }
- }
- }
|