2003-10-25 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
[mono.git] / mcs / class / System.XML / System.Xml.Schema / XmlSchemaAppInfo.cs
1 // Author: Dwivedi, Ajay kumar\r
2 //            Adwiv@Yahoo.com\r
3 using System;\r
4 using System.Xml;\r
5 using System.Xml.Serialization;\r
6 \r
7 namespace System.Xml.Schema\r
8 {\r
9         /// <summary>\r
10         /// Summary description for XmlSchemaAppInfo.\r
11         /// </summary>\r
12         public class XmlSchemaAppInfo : XmlSchemaObject\r
13         {\r
14                 private XmlNode[] markup;\r
15                 private string source;\r
16 \r
17                 public XmlSchemaAppInfo()\r
18                 {\r
19                 }\r
20 \r
21                 [System.Xml.Serialization.XmlAttribute("source")]\r
22                 public string Source \r
23                 {\r
24                         get{ return  source; } \r
25                         set{ source = value; }\r
26                 }\r
27 \r
28                 [XmlAnyElement]\r
29                 [XmlText]\r
30                 public XmlNode[] Markup \r
31                 {\r
32                         get{ return  markup; }\r
33                         set{ markup = value; }\r
34                 }\r
35 \r
36                 //<appinfo\r
37                 //  source = anyURI>\r
38                 //  Content: ({any})*\r
39                 //</appinfo>\r
40                 internal static XmlSchemaAppInfo Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip)\r
41                 {\r
42                         skip = false;\r
43                         XmlSchemaAppInfo appinfo = new XmlSchemaAppInfo();\r
44                         reader.MoveToElement();\r
45 \r
46                         if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "appinfo")\r
47                         {\r
48                                 error(h,"Should not happen :1: XmlSchemaAppInfo.Read, name="+reader.Name,null);\r
49                                 reader.SkipToEnd();\r
50                                 return null;\r
51                         }\r
52 \r
53                         appinfo.LineNumber = reader.LineNumber;\r
54                         appinfo.LinePosition = reader.LinePosition;\r
55                         appinfo.SourceUri = reader.BaseURI;\r
56 \r
57                         while(reader.MoveToNextAttribute())\r
58                         {\r
59                                 if(reader.Name == "source")\r
60                                 {\r
61                                         appinfo.source = reader.Value;\r
62                                 }\r
63                                 else\r
64                                 {\r
65                                         error(h,reader.Name + " is not a valid attribute for appinfo",null);\r
66                                 }\r
67                         }\r
68 \r
69                         reader.MoveToElement();\r
70                         if(reader.IsEmptyElement)\r
71                                 return appinfo;\r
72 \r
73                         //Content {any}*\r
74                         //FIXME: This is a pure Quick Hack; There must be a another method;\r
75                         XmlDocument xmldoc = new XmlDocument();\r
76                         xmldoc.AppendChild(xmldoc.ReadNode(reader));\r
77                         XmlNode root = xmldoc.FirstChild;\r
78                         if(root != null && root.ChildNodes != null)\r
79                         {\r
80                                 appinfo.Markup = new XmlNode[root.ChildNodes.Count];\r
81                                 for(int i=0;i<root.ChildNodes.Count;i++)\r
82                                 {\r
83                                         appinfo.Markup[i] = root.ChildNodes[i];\r
84                                 }\r
85                         }\r
86                         if(reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement)\r
87                                 skip = true;\r
88                         return appinfo;\r
89                 }\r
90         }\r
91 }\r