1 // Author: Dwivedi, Ajay kumar
\r
5 using System.Xml.Serialization;
\r
7 namespace System.Xml.Schema
\r
10 /// Summary description for XmlSchemaAnnotation.
\r
12 public class XmlSchemaAnnotation : XmlSchemaObject
\r
15 private XmlSchemaObjectCollection items;
\r
16 private XmlAttribute[] unhandledAttributes;
\r
17 private static string xmlname = "annotation";
\r
18 public XmlSchemaAnnotation()
\r
20 items = new XmlSchemaObjectCollection();
\r
23 [System.Xml.Serialization.XmlAttribute("id")]
\r
30 [XmlElement("appinfo",typeof(XmlSchemaAppInfo),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
31 [XmlElement("documentation",typeof(XmlSchemaDocumentation),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
32 public XmlSchemaObjectCollection Items
\r
34 get{ return items; }
\r
38 public XmlAttribute[] UnhandledAttributes
\r
40 get{ return unhandledAttributes; }
\r
41 set{ unhandledAttributes = value; }
\r
45 internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
\r
51 internal int Validate(ValidationEventHandler h)
\r
58 // {any attributes with non-schema namespace . . .}>
\r
59 // Content: (appinfo | documentation)*
\r
61 internal static XmlSchemaAnnotation Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
63 XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
\r
64 reader.MoveToElement();
\r
66 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
\r
68 error(h,"Should not happen :1: XmlSchemaAnnotation.Read, name="+reader.Name,null);
\r
73 annotation.LineNumber = reader.LineNumber;
\r
74 annotation.LinePosition = reader.LinePosition;
\r
75 annotation.SourceUri = reader.BaseURI;
\r
78 while(reader.MoveToNextAttribute())
\r
80 if(reader.Name == "id")
\r
82 annotation.Id = reader.Value;
\r
84 else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
\r
86 error(h,reader.Name + " is not a valid attribute for annotation",null);
\r
90 //TODO: Add to Unhandled attributes
\r
94 reader.MoveToElement();
\r
95 if(reader.IsEmptyElement)
\r
98 //Content: (appinfo | documentation)*
\r
99 while(reader.ReadNextElement())
\r
101 if(reader.NodeType == XmlNodeType.EndElement)
\r
103 if(reader.LocalName != xmlname)
\r
104 error(h,"Should not happen :2: XmlSchemaAnnotation.Read, name="+reader.Name,null);
\r
107 if(reader.LocalName == "appinfo")
\r
109 XmlSchemaAppInfo appinfo = XmlSchemaAppInfo.Read(reader,h);
\r
110 if(appinfo != null)
\r
111 annotation.items.Add(appinfo);
\r
114 if(reader.LocalName == "documentation")
\r
116 XmlSchemaDocumentation documentation = XmlSchemaDocumentation.Read(reader,h);
\r
117 if(documentation != null)
\r
118 annotation.items.Add(documentation);
\r
121 reader.RaiseInvalidElementError();
\r