1 // Author: Dwivedi, Ajay kumar
\r
5 using System.Xml.Serialization;
\r
7 namespace System.Xml.Schema
\r
10 /// Summary description for XmlSchemaImport.
\r
12 public class XmlSchemaImport : XmlSchemaExternal
\r
14 private XmlSchemaAnnotation annotation;
\r
15 private string nameSpace;
\r
16 private static string xmlname = "import";
\r
18 public XmlSchemaImport()
\r
22 [XmlElement("annotation",Namespace="http://www.w3.org/2001/XMLSchema")]
\r
23 public XmlSchemaAnnotation Annotation
\r
25 get{ return annotation; }
\r
26 set{ annotation = value; }
\r
29 [System.Xml.Serialization.XmlAttribute("namespace")]
\r
30 public string Namespace
\r
32 get{ return nameSpace; }
\r
33 set{ nameSpace = value; }
\r
37 // namespace = anyURI
\r
38 // schemaLocation = anyURI
\r
39 // {any attributes with non-schema namespace . . .}>
\r
40 // Content: (annotation?)
\r
42 internal static XmlSchemaImport Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
44 XmlSchemaImport import = new XmlSchemaImport();
\r
45 reader.MoveToElement();
\r
47 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "import")
\r
49 error(h,"Should not happen :1: XmlSchemaImport.Read, name="+reader.Name,null);
\r
54 import.LineNumber = reader.LineNumber;
\r
55 import.LinePosition = reader.LinePosition;
\r
56 import.SourceUri = reader.BaseURI;
\r
58 while(reader.MoveToNextAttribute())
\r
60 if(reader.Name == "id")
\r
62 import.Id = reader.Value;
\r
64 else if(reader.Name == "namespace")
\r
66 import.nameSpace = reader.Value;
\r
68 else if(reader.Name == "schemaLocation")
\r
70 import.SchemaLocation = reader.Value;
\r
72 else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
\r
74 error(h,reader.Name + " is not a valid attribute for import",null);
\r
78 //TODO: Add to Unhandled attributes
\r
82 reader.MoveToElement();
\r
83 if(reader.IsEmptyElement)
\r
86 // Content: (annotation?)
\r
88 while(reader.ReadNextElement())
\r
90 if(reader.NodeType == XmlNodeType.EndElement)
\r
92 if(reader.LocalName != xmlname)
\r
93 error(h,"Should not happen :2: XmlSchemaImport.Read, name="+reader.Name,null);
\r
96 if(level <= 1 && reader.LocalName == "annotation")
\r
98 level = 2; //Only one annotation
\r
99 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
\r
100 if(annotation != null)
\r
101 import.Annotation = annotation;
\r
104 reader.RaiseInvalidElementError();
\r