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.targetNS);
\r
60 if(Public==null||Public == "")
\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 anyURI");
\r
68 if(this.Id != null && !XmlSchemaUtil.CheckID(Id))
\r
69 error(h, "id must be a valid ID");
\r
75 internal int Validate(ValidationEventHandler h)
\r
85 // {any attributes with non-schema namespace . . .}>
\r
86 // Content: (annotation?)
\r
88 internal static XmlSchemaNotation Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
90 XmlSchemaNotation notation = new XmlSchemaNotation();
\r
91 reader.MoveToElement();
\r
93 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
\r
95 error(h,"Should not happen :1: XmlSchemaInclude.Read, name="+reader.Name,null);
\r
100 notation.LineNumber = reader.LineNumber;
\r
101 notation.LinePosition = reader.LinePosition;
\r
102 notation.SourceUri = reader.BaseURI;
\r
104 while(reader.MoveToNextAttribute())
\r
106 if(reader.Name == "id")
\r
108 notation.Id = reader.Value;
\r
110 else if(reader.Name == "name")
\r
112 notation.name = reader.Value;
\r
114 else if(reader.Name == "public")
\r
116 notation.pub = reader.Value;
\r
118 else if(reader.Name == "system")
\r
120 notation.system = reader.Value;
\r
122 else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
\r
124 error(h,reader.Name + " is not a valid attribute for notation",null);
\r
128 //TODO: Add to Unhandled attributes
\r
132 reader.MoveToElement();
\r
133 if(reader.IsEmptyElement)
\r
136 // Content: (annotation?)
\r
138 while(reader.ReadNextElement())
\r
140 if(reader.NodeType == XmlNodeType.EndElement)
\r
142 if(reader.LocalName != xmlname)
\r
143 error(h,"Should not happen :2: XmlSchemaNotation.Read, name="+reader.Name,null);
\r
146 if(level <= 1 && reader.LocalName == "annotation")
\r
148 level = 2; //Only one annotation
\r
149 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
\r
150 if(annotation != null)
\r
151 notation.Annotation = annotation;
\r
154 reader.RaiseInvalidElementError();
\r