-// Author: Dwivedi, Ajay kumar\r
-// Adwiv@Yahoo.com\r
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;\r
-using System.Collections;\r
-using System.Xml;\r
-using System.Xml.Serialization;\r
-\r
-namespace System.Xml.Schema\r
-{\r
- /// <summary>\r
- /// Summary description for XmlSchemaAnnotation.\r
- /// </summary>\r
- public class XmlSchemaAnnotation : XmlSchemaObject\r
- {\r
- private string id;\r
- private XmlSchemaObjectCollection items;\r
- private XmlAttribute[] unhandledAttributes;\r
- const string xmlname = "annotation";\r
-\r
- public XmlSchemaAnnotation()\r
- {\r
- items = new XmlSchemaObjectCollection();\r
- }\r
-\r
- [System.Xml.Serialization.XmlAttribute("id", DataType="ID")]\r
- public string Id \r
- {\r
- get{ return id; } \r
- set{ id = value; }\r
- }\r
- \r
- [XmlElement("appinfo",typeof(XmlSchemaAppInfo))]\r
- [XmlElement("documentation",typeof(XmlSchemaDocumentation))]\r
- public XmlSchemaObjectCollection Items\r
- {\r
- get{ return items; }\r
- }\r
- \r
- [XmlAnyAttribute]\r
- public XmlAttribute[] UnhandledAttributes \r
- {\r
- get\r
- {\r
- if(unhandledAttributeList != null)\r
- {\r
- unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));\r
- unhandledAttributeList = null;\r
- }\r
- return unhandledAttributes;\r
- }\r
- set\r
- { \r
- unhandledAttributes = value; \r
- unhandledAttributeList = null;\r
- }\r
- }\r
-\r
- internal override int Compile(ValidationEventHandler h, XmlSchema schema)\r
- {\r
- // If this is already compiled this time, simply skip.\r
- if (CompilationId == schema.CompilationId)\r
- return 0;\r
-\r
- this.CompilationId = schema.CompilationId;\r
- return 0;\r
- }\r
- \r
- internal override int Validate(ValidationEventHandler h, XmlSchema schema)\r
- {\r
- return 0;\r
- }\r
-\r
- //<annotation\r
- // id = ID\r
- // {any attributes with non-schema namespace . . .}>\r
- // Content: (appinfo | documentation)*\r
- //</annotation>\r
- internal static XmlSchemaAnnotation Read(XmlSchemaReader reader, ValidationEventHandler h)\r
- {\r
- XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();\r
- reader.MoveToElement();\r
-\r
- if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)\r
- {\r
- error(h,"Should not happen :1: XmlSchemaAnnotation.Read, name="+reader.Name,null);\r
- reader.SkipToEnd();\r
- return null;\r
- }\r
-\r
- annotation.LineNumber = reader.LineNumber;\r
- annotation.LinePosition = reader.LinePosition;\r
- annotation.SourceUri = reader.BaseURI;\r
-\r
- //Read Attributes\r
- while(reader.MoveToNextAttribute())\r
- {\r
- if(reader.Name == "id")\r
- {\r
- annotation.Id = reader.Value;\r
- }\r
- else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)\r
- {\r
- error(h,reader.Name + " is not a valid attribute for annotation",null);\r
- }\r
- else\r
- {\r
- XmlSchemaUtil.ReadUnhandledAttribute(reader,annotation);\r
- }\r
- }\r
- \r
- reader.MoveToElement();\r
- if(reader.IsEmptyElement)\r
- return annotation;\r
-\r
- //Content: (appinfo | documentation)*\r
- bool skip = false;\r
- string expectedEnd = null;\r
- while(!reader.EOF)\r
- {\r
- if(skip) \r
- skip=false;\r
- else \r
- reader.ReadNextElement();\r
-\r
- if(reader.NodeType == XmlNodeType.EndElement)\r
- {\r
- bool end = true;\r
- string expected = xmlname;\r
- if(expectedEnd != null)\r
- {\r
- expected = expectedEnd;\r
- expectedEnd = null;\r
- end = false;\r
- }\r
- if(reader.LocalName != expected)\r
- error(h,"Should not happen :2: XmlSchemaAnnotation.Read, name="+reader.Name+",expected="+expected,null);\r
- if (end)\r
- break;\r
- else\r
- continue;\r
- }\r
- if(reader.LocalName == "appinfo")\r
- {\r
- XmlSchemaAppInfo appinfo = XmlSchemaAppInfo.Read(reader,h,out skip);\r
- if(appinfo != null)\r
- annotation.items.Add(appinfo);\r
- continue;\r
- }\r
- if(reader.LocalName == "documentation")\r
- {\r
- XmlSchemaDocumentation documentation = XmlSchemaDocumentation.Read(reader,h, out skip);\r
- if(documentation != null)\r
- annotation.items.Add(documentation);\r
- continue;\r
- }\r
- reader.RaiseInvalidElementError();\r
- }\r
- return annotation;\r
- }\r
- }\r
-}\r
+using System;
+using System.Collections;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAnnotation.
+ /// </summary>
+ public class XmlSchemaAnnotation : XmlSchemaObject
+ {
+ private string id;
+ private XmlSchemaObjectCollection items;
+ private XmlAttribute[] unhandledAttributes;
+ const string xmlname = "annotation";
+
+ public XmlSchemaAnnotation()
+ {
+ items = new XmlSchemaObjectCollection();
+ }
+
+ [System.Xml.Serialization.XmlAttribute("id", DataType="ID")]
+ public string Id
+ {
+ get{ return id; }
+ set{ id = value; }
+ }
+
+ [XmlElement("appinfo",typeof(XmlSchemaAppInfo))]
+ [XmlElement("documentation",typeof(XmlSchemaDocumentation))]
+ public XmlSchemaObjectCollection Items
+ {
+ get{ return items; }
+ }
+
+ [XmlAnyAttribute]
+ public XmlAttribute[] UnhandledAttributes
+ {
+ get
+ {
+ if(unhandledAttributeList != null)
+ {
+ unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
+ unhandledAttributeList = null;
+ }
+ return unhandledAttributes;
+ }
+ set
+ {
+ unhandledAttributes = value;
+ unhandledAttributeList = null;
+ }
+ }
+
+ internal override int Compile(ValidationEventHandler h, XmlSchema schema)
+ {
+ // If this is already compiled this time, simply skip.
+ if (CompilationId == schema.CompilationId)
+ return 0;
+
+ this.CompilationId = schema.CompilationId;
+ return 0;
+ }
+
+ internal override int Validate(ValidationEventHandler h, XmlSchema schema)
+ {
+ return 0;
+ }
+
+ //<annotation
+ // id = ID
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (appinfo | documentation)*
+ //</annotation>
+ internal static XmlSchemaAnnotation Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAnnotation.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ annotation.LineNumber = reader.LineNumber;
+ annotation.LinePosition = reader.LinePosition;
+ annotation.SourceUri = reader.BaseURI;
+
+ //Read Attributes
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ annotation.Id = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for annotation",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,annotation);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return annotation;
+
+ //Content: (appinfo | documentation)*
+ bool skip = false;
+ string expectedEnd = null;
+ while(!reader.EOF)
+ {
+ if(skip)
+ skip=false;
+ else
+ reader.ReadNextElement();
+
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ bool end = true;
+ string expected = xmlname;
+ if(expectedEnd != null)
+ {
+ expected = expectedEnd;
+ expectedEnd = null;
+ end = false;
+ }
+ if(reader.LocalName != expected)
+ error(h,"Should not happen :2: XmlSchemaAnnotation.Read, name="+reader.Name+",expected="+expected,null);
+ if (end)
+ break;
+ else
+ continue;
+ }
+ if(reader.LocalName == "appinfo")
+ {
+ XmlSchemaAppInfo appinfo = XmlSchemaAppInfo.Read(reader,h,out skip);
+ if(appinfo != null)
+ annotation.items.Add(appinfo);
+ continue;
+ }
+ if(reader.LocalName == "documentation")
+ {
+ XmlSchemaDocumentation documentation = XmlSchemaDocumentation.Read(reader,h, out skip);
+ if(documentation != null)
+ annotation.items.Add(documentation);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return annotation;
+ }
+ }
+}