1 // Author: Dwivedi, Ajay kumar
\r
4 using System.Xml.Serialization;
\r
7 namespace System.Xml.Schema
\r
10 /// Summary description for XmlSchemaNotation.
\r
12 public class XmlSchemaNotation : XmlSchemaAnnotated
\r
14 private string name;
\r
16 private string system;
\r
17 private XmlQualifiedName qualifiedName;
\r
18 private static string xmlname = "notation";
\r
20 public XmlSchemaNotation()
\r
23 [System.Xml.Serialization.XmlAttribute("name")]
\r
26 get{ return name; }
\r
27 set{ name = value; }
\r
29 [System.Xml.Serialization.XmlAttribute("public")]
\r
30 public string Public
\r
35 [System.Xml.Serialization.XmlAttribute("system")]
\r
36 public string System
\r
38 get{ return system; }
\r
39 set{ system = value; }
\r
43 internal XmlQualifiedName QualifiedName
\r
45 get{ return qualifiedName;}
\r
48 // 1. name and public must be present
\r
49 // public and system must be anyURI
\r
51 internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
\r
54 error(h,"Required attribute name must be present");
\r
55 else if(!XmlSchemaUtil.CheckNCName(this.name))
\r
56 error(h,"attribute name must be NCName");
\r
58 qualifiedName = new XmlQualifiedName(Name,info.TargetNamespace);
\r
61 error(h,"public must be present");
\r
62 else if(!XmlSchemaUtil.CheckAnyUri(Public))
\r
63 error(h,"public must be anyURI");
\r
65 if(system != null && !XmlSchemaUtil.CheckAnyUri(system))
\r
66 error(h,"system must be present and of Type anyURI");
\r
68 XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
\r
74 internal int Validate(ValidationEventHandler h)
\r
84 // {any attributes with non-schema namespace . . .}>
\r
85 // Content: (annotation?)
\r
87 internal static XmlSchemaNotation Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
89 XmlSchemaNotation notation = new XmlSchemaNotation();
\r
90 reader.MoveToElement();
\r
92 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
\r
94 error(h,"Should not happen :1: XmlSchemaInclude.Read, name="+reader.Name,null);
\r
99 notation.LineNumber = reader.LineNumber;
\r
100 notation.LinePosition = reader.LinePosition;
\r
101 notation.SourceUri = reader.BaseURI;
\r
103 while(reader.MoveToNextAttribute())
\r
105 if(reader.Name == "id")
\r
107 notation.Id = reader.Value;
\r
109 else if(reader.Name == "name")
\r
111 notation.name = reader.Value;
\r
113 else if(reader.Name == "public")
\r
115 notation.pub = reader.Value;
\r
117 else if(reader.Name == "system")
\r
119 notation.system = reader.Value;
\r
121 else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
\r
123 error(h,reader.Name + " is not a valid attribute for notation",null);
\r
127 XmlSchemaUtil.ReadUnhandledAttribute(reader,notation);
\r
131 reader.MoveToElement();
\r
132 if(reader.IsEmptyElement)
\r
135 // Content: (annotation?)
\r
137 while(reader.ReadNextElement())
\r
139 if(reader.NodeType == XmlNodeType.EndElement)
\r
141 if(reader.LocalName != xmlname)
\r
142 error(h,"Should not happen :2: XmlSchemaNotation.Read, name="+reader.Name,null);
\r
145 if(level <= 1 && reader.LocalName == "annotation")
\r
147 level = 2; //Only one annotation
\r
148 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
\r
149 if(annotation != null)
\r
150 notation.Annotation = annotation;
\r
153 reader.RaiseInvalidElementError();
\r