1 // Author: Dwivedi, Ajay kumar
\r
5 // Permission is hereby granted, free of charge, to any person obtaining
6 // a copy of this software and associated documentation files (the
7 // "Software"), to deal in the Software without restriction, including
8 // without limitation the rights to use, copy, modify, merge, publish,
9 // distribute, sublicense, and/or sell copies of the Software, and to
10 // permit persons to whom the Software is furnished to do so, subject to
11 // the following conditions:
13 // The above copyright notice and this permission notice shall be
14 // included in all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 using System.Xml.Serialization;
\r
28 namespace System.Xml.Schema
\r
31 /// Summary description for XmlSchemaNotation.
\r
33 public class XmlSchemaNotation : XmlSchemaAnnotated
\r
35 private string name;
\r
37 private string system;
\r
38 private XmlQualifiedName qualifiedName;
\r
39 const string xmlname = "notation";
\r
41 public XmlSchemaNotation()
\r
44 [System.Xml.Serialization.XmlAttribute("name")]
\r
47 get{ return name; }
\r
48 set{ name = value; }
\r
50 [System.Xml.Serialization.XmlAttribute("public")]
\r
51 public string Public
\r
56 [System.Xml.Serialization.XmlAttribute("system")]
\r
57 public string System
\r
59 get{ return system; }
\r
60 set{ system = value; }
\r
64 internal XmlQualifiedName QualifiedName
\r
66 get{ return qualifiedName;}
\r
69 // 1. name and public must be present
\r
70 // public and system must be anyURI
\r
71 internal override int Compile(ValidationEventHandler h, XmlSchema schema)
\r
73 // If this is already compiled this time, simply skip.
\r
74 if (this.IsComplied (schema.CompilationId))
\r
78 error(h,"Required attribute name must be present");
\r
79 else if(!XmlSchemaUtil.CheckNCName(this.name))
\r
80 error(h,"attribute name must be NCName");
\r
82 qualifiedName = new XmlQualifiedName(Name,schema.TargetNamespace);
\r
85 error(h,"public must be present");
\r
86 else if(!XmlSchemaUtil.CheckAnyUri(Public))
\r
87 error(h,"public must be anyURI");
\r
89 if(system != null && !XmlSchemaUtil.CheckAnyUri(system))
\r
90 error(h,"system must be present and of Type anyURI");
\r
92 XmlSchemaUtil.CompileID(Id,this,schema.IDCollection,h);
\r
97 internal override int Validate(ValidationEventHandler h, XmlSchema schema)
\r
105 // public = anyURI
\r
106 // system = anyURI
\r
107 // {any attributes with non-schema namespace . . .}>
\r
108 // Content: (annotation?)
\r
110 internal static XmlSchemaNotation Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
112 XmlSchemaNotation notation = new XmlSchemaNotation();
\r
113 reader.MoveToElement();
\r
115 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
\r
117 error(h,"Should not happen :1: XmlSchemaInclude.Read, name="+reader.Name,null);
\r
122 notation.LineNumber = reader.LineNumber;
\r
123 notation.LinePosition = reader.LinePosition;
\r
124 notation.SourceUri = reader.BaseURI;
\r
126 while(reader.MoveToNextAttribute())
\r
128 if(reader.Name == "id")
\r
130 notation.Id = reader.Value;
\r
132 else if(reader.Name == "name")
\r
134 notation.name = reader.Value;
\r
136 else if(reader.Name == "public")
\r
138 notation.pub = reader.Value;
\r
140 else if(reader.Name == "system")
\r
142 notation.system = reader.Value;
\r
144 else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
\r
146 error(h,reader.Name + " is not a valid attribute for notation",null);
\r
150 XmlSchemaUtil.ReadUnhandledAttribute(reader,notation);
\r
154 reader.MoveToElement();
\r
155 if(reader.IsEmptyElement)
\r
158 // Content: (annotation?)
\r
160 while(reader.ReadNextElement())
\r
162 if(reader.NodeType == XmlNodeType.EndElement)
\r
164 if(reader.LocalName != xmlname)
\r
165 error(h,"Should not happen :2: XmlSchemaNotation.Read, name="+reader.Name,null);
\r
168 if(level <= 1 && reader.LocalName == "annotation")
\r
170 level = 2; //Only one annotation
\r
171 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
\r
172 if(annotation != null)
\r
173 notation.Annotation = annotation;
\r
176 reader.RaiseInvalidElementError();
\r