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 const 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
50 internal override int Compile(ValidationEventHandler h, XmlSchema schema)
\r
52 // If this is already compiled this time, simply skip.
\r
53 if (this.IsComplied (schema.CompilationId))
\r
57 error(h,"Required attribute name must be present");
\r
58 else if(!XmlSchemaUtil.CheckNCName(this.name))
\r
59 error(h,"attribute name must be NCName");
\r
61 qualifiedName = new XmlQualifiedName(Name,schema.TargetNamespace);
\r
64 error(h,"public must be present");
\r
65 else if(!XmlSchemaUtil.CheckAnyUri(Public))
\r
66 error(h,"public must be anyURI");
\r
68 if(system != null && !XmlSchemaUtil.CheckAnyUri(system))
\r
69 error(h,"system must be present and of Type anyURI");
\r
71 XmlSchemaUtil.CompileID(Id,this,schema.IDCollection,h);
\r
76 internal override int Validate(ValidationEventHandler h, XmlSchema schema)
\r
86 // {any attributes with non-schema namespace . . .}>
\r
87 // Content: (annotation?)
\r
89 internal static XmlSchemaNotation Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
91 XmlSchemaNotation notation = new XmlSchemaNotation();
\r
92 reader.MoveToElement();
\r
94 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
\r
96 error(h,"Should not happen :1: XmlSchemaInclude.Read, name="+reader.Name,null);
\r
101 notation.LineNumber = reader.LineNumber;
\r
102 notation.LinePosition = reader.LinePosition;
\r
103 notation.SourceUri = reader.BaseURI;
\r
105 while(reader.MoveToNextAttribute())
\r
107 if(reader.Name == "id")
\r
109 notation.Id = reader.Value;
\r
111 else if(reader.Name == "name")
\r
113 notation.name = reader.Value;
\r
115 else if(reader.Name == "public")
\r
117 notation.pub = reader.Value;
\r
119 else if(reader.Name == "system")
\r
121 notation.system = reader.Value;
\r
123 else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
\r
125 error(h,reader.Name + " is not a valid attribute for notation",null);
\r
129 XmlSchemaUtil.ReadUnhandledAttribute(reader,notation);
\r
133 reader.MoveToElement();
\r
134 if(reader.IsEmptyElement)
\r
137 // Content: (annotation?)
\r
139 while(reader.ReadNextElement())
\r
141 if(reader.NodeType == XmlNodeType.EndElement)
\r
143 if(reader.LocalName != xmlname)
\r
144 error(h,"Should not happen :2: XmlSchemaNotation.Read, name="+reader.Name,null);
\r
147 if(level <= 1 && reader.LocalName == "annotation")
\r
149 level = 2; //Only one annotation
\r
150 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
\r
151 if(annotation != null)
\r
152 notation.Annotation = annotation;
\r
155 reader.RaiseInvalidElementError();
\r