2002-05-25 Dwivedi, Ajay kumar <adwiv@yahoo.com>
[mono.git] / mcs / class / System.XML / System.Xml.Schema / XmlSchemaGroup.cs
1 // Author: Dwivedi, Ajay kumar\r
2 //            Adwiv@Yahoo.com\r
3 using System;\r
4 using System.Xml.Serialization;\r
5 using System.Xml;\r
6 \r
7 namespace System.Xml.Schema\r
8 {\r
9         /// <summary>\r
10         /// Summary description for XmlSchemaGroup.\r
11         /// </summary>\r
12         public class XmlSchemaGroup : XmlSchemaAnnotated\r
13         {\r
14                 private string name;\r
15                 private XmlSchemaGroupBase particle;\r
16                 private XmlQualifiedName qualifiedName;\r
17                 private int errorCount;\r
18 \r
19                 public XmlSchemaGroup()\r
20                 {\r
21                 }\r
22 \r
23                 [System.Xml.Serialization.XmlAttribute("name")]\r
24                 public string Name \r
25                 {\r
26                         get{ return  name; } \r
27                         set{ name = value; }\r
28                 }\r
29 \r
30                 [XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]\r
31                 [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]\r
32                 [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]\r
33                 public XmlSchemaGroupBase Particle\r
34                 {\r
35                         get{ return  particle; }\r
36                         set{ particle = value; }\r
37                 }\r
38 \r
39                 [XmlIgnore]\r
40                 internal XmlQualifiedName QualifiedName \r
41                 {\r
42                         get{ return qualifiedName;}\r
43                 }\r
44 \r
45                 // 1. name must be present\r
46                 [MonoTODO]\r
47                 internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)\r
48                 {\r
49                         if(Name == null)\r
50                                 error(h,"Required attribute name must be present");\r
51                         else if(!XmlSchemaUtil.CheckNCName(this.name)) \r
52                                 error(h,"attribute name must be NCName");\r
53                         else\r
54                                 qualifiedName = new XmlQualifiedName(Name,info.targetNS);\r
55                         \r
56                         if(Particle == null)\r
57                         {\r
58                                 error(h,"Particle is required");\r
59                         }\r
60                         else if(Particle is XmlSchemaChoice)\r
61                         {\r
62                                 errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);\r
63                         }\r
64                         else if(Particle is XmlSchemaSequence)\r
65                         {\r
66                                 errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);\r
67                         }\r
68                         else if(Particle is XmlSchemaAll)\r
69                         {\r
70                                 errorCount += ((XmlSchemaAll)Particle).Compile(h,info);\r
71                         }\r
72                         else\r
73                         {\r
74                                 error(h,"only all,choice or sequence are allowed");\r
75                         }\r
76 \r
77                         if(this.Id != null && !XmlSchemaUtil.CheckID(Id))\r
78                                 error(h, "id must be a valid ID");\r
79 \r
80                         return errorCount;\r
81                 }\r
82                 \r
83                 [MonoTODO]\r
84                 internal int Validate(ValidationEventHandler h)\r
85                 {\r
86                         return errorCount;\r
87                 }\r
88                 \r
89                 internal void error(ValidationEventHandler handle,string message)\r
90                 {\r
91                         errorCount++;\r
92                         ValidationHandler.RaiseValidationError(handle,this,message);\r
93                 }\r
94         }\r
95 }\r