1 // Author: Dwivedi, Ajay kumar
\r
4 using System.Collections;
\r
6 using System.Xml.Serialization;
\r
8 namespace System.Xml.Schema
\r
11 /// Summary description for XmlSchemaAnnotation.
\r
13 public class XmlSchemaAnnotation : XmlSchemaObject
\r
16 private XmlSchemaObjectCollection items;
\r
17 private XmlAttribute[] unhandledAttributes;
\r
18 private static string xmlname = "annotation";
\r
19 public XmlSchemaAnnotation()
\r
21 items = new XmlSchemaObjectCollection();
\r
24 [System.Xml.Serialization.XmlAttribute("id")]
\r
31 [XmlElement("appinfo",typeof(XmlSchemaAppInfo),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
32 [XmlElement("documentation",typeof(XmlSchemaDocumentation),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
33 public XmlSchemaObjectCollection Items
\r
35 get{ return items; }
\r
39 public XmlAttribute[] UnhandledAttributes
\r
43 if(unhandledAttributeList != null)
\r
45 unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
\r
46 unhandledAttributeList = null;
\r
48 return unhandledAttributes;
\r
52 unhandledAttributes = value;
\r
53 unhandledAttributeList = null;
\r
58 internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
\r
64 internal int Validate(ValidationEventHandler h)
\r
71 // {any attributes with non-schema namespace . . .}>
\r
72 // Content: (appinfo | documentation)*
\r
74 internal static XmlSchemaAnnotation Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
76 XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
\r
77 reader.MoveToElement();
\r
79 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
\r
81 error(h,"Should not happen :1: XmlSchemaAnnotation.Read, name="+reader.Name,null);
\r
86 annotation.LineNumber = reader.LineNumber;
\r
87 annotation.LinePosition = reader.LinePosition;
\r
88 annotation.SourceUri = reader.BaseURI;
\r
91 while(reader.MoveToNextAttribute())
\r
93 if(reader.Name == "id")
\r
95 annotation.Id = reader.Value;
\r
97 else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
\r
99 error(h,reader.Name + " is not a valid attribute for annotation",null);
\r
103 XmlSchemaUtil.ReadUnhandledAttribute(reader,annotation);
\r
107 reader.MoveToElement();
\r
108 if(reader.IsEmptyElement)
\r
111 //Content: (appinfo | documentation)*
\r
113 string expectedEnd = null;
\r
119 reader.ReadNextElement();
\r
121 if(reader.NodeType == XmlNodeType.EndElement)
\r
124 string expected = xmlname;
\r
125 if(expectedEnd != null)
\r
127 expected = expectedEnd;
\r
128 expectedEnd = null;
\r
131 if(reader.LocalName != expected)
\r
132 error(h,"Should not happen :2: XmlSchemaAnnotation.Read, name="+reader.Name+",expected="+expected,null);
\r
138 if(reader.LocalName == "appinfo")
\r
140 XmlSchemaAppInfo appinfo = XmlSchemaAppInfo.Read(reader,h,out skip);
\r
141 if(appinfo != null)
\r
142 annotation.items.Add(appinfo);
\r
143 expectedEnd = "appinfo";
\r
146 if(reader.LocalName == "documentation")
\r
148 XmlSchemaDocumentation documentation = XmlSchemaDocumentation.Read(reader,h, out skip);
\r
149 if(documentation != null)
\r
150 annotation.items.Add(documentation);
\r
151 expectedEnd = "documentation";
\r
154 reader.RaiseInvalidElementError();
\r