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.
26 using System.Xml.Serialization;
\r
28 namespace System.Xml.Schema
\r
31 /// Summary description for XmlSchemaImport.
\r
33 public class XmlSchemaImport : XmlSchemaExternal
\r
35 private XmlSchemaAnnotation annotation;
\r
36 private string nameSpace;
\r
37 const string xmlname = "import";
\r
39 public XmlSchemaImport()
\r
43 [System.Xml.Serialization.XmlAttribute("namespace")]
\r
44 public string Namespace
\r
46 get{ return nameSpace; }
\r
47 set{ nameSpace = value; }
\r
50 [XmlElement("annotation",Namespace=XmlSchema.Namespace)]
\r
51 public XmlSchemaAnnotation Annotation
\r
53 get{ return annotation; }
\r
54 set{ annotation = value; }
\r
58 // namespace = anyURI
\r
59 // schemaLocation = anyURI
\r
60 // {any attributes with non-schema namespace . . .}>
\r
61 // Content: (annotation?)
\r
63 internal static XmlSchemaImport Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
65 XmlSchemaImport import = new XmlSchemaImport();
\r
66 reader.MoveToElement();
\r
68 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "import")
\r
70 error(h,"Should not happen :1: XmlSchemaImport.Read, name="+reader.Name,null);
\r
75 import.LineNumber = reader.LineNumber;
\r
76 import.LinePosition = reader.LinePosition;
\r
77 import.SourceUri = reader.BaseURI;
\r
79 while(reader.MoveToNextAttribute())
\r
81 if(reader.Name == "id")
\r
83 import.Id = reader.Value;
\r
85 else if(reader.Name == "namespace")
\r
87 import.nameSpace = reader.Value;
\r
89 else if(reader.Name == "schemaLocation")
\r
91 import.SchemaLocation = reader.Value;
\r
93 else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
\r
95 error(h,reader.Name + " is not a valid attribute for import",null);
\r
99 XmlSchemaUtil.ReadUnhandledAttribute(reader,import);
\r
103 reader.MoveToElement();
\r
104 if(reader.IsEmptyElement)
\r
107 // Content: (annotation?)
\r
109 while(reader.ReadNextElement())
\r
111 if(reader.NodeType == XmlNodeType.EndElement)
\r
113 if(reader.LocalName != xmlname)
\r
114 error(h,"Should not happen :2: XmlSchemaImport.Read, name="+reader.Name,null);
\r
117 if(level <= 1 && reader.LocalName == "annotation")
\r
119 level = 2; //Only one annotation
\r
120 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
\r
121 if(annotation != null)
\r
122 import.Annotation = annotation;
\r
125 reader.RaiseInvalidElementError();
\r