1 // Author: Dwivedi, Ajay kumar
\r
4 using System.Xml.Serialization;
\r
7 namespace System.Xml.Schema
\r
10 /// Summary description for XmlSchemaInclude.
\r
12 public class XmlSchemaInclude : XmlSchemaExternal
\r
14 private XmlSchemaAnnotation annotation;
\r
15 public static string xmlname = "include";
\r
17 public XmlSchemaInclude()
\r
20 [XmlElement("annotation",Namespace="http://www.w3.org/2001/XMLSchema")]
\r
21 public XmlSchemaAnnotation Annotation
\r
23 get{ return annotation; }
\r
24 set{ annotation = value; }
\r
28 // schemaLocation = anyURI
\r
29 // {any attributes with non-schema namespace . . .}>
\r
30 // Content: (annotation?)
\r
32 internal static XmlSchemaInclude Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
34 XmlSchemaInclude include = new XmlSchemaInclude();
\r
35 reader.MoveToElement();
\r
37 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
\r
39 error(h,"Should not happen :1: XmlSchemaInclude.Read, name="+reader.Name,null);
\r
44 include.LineNumber = reader.LineNumber;
\r
45 include.LinePosition = reader.LinePosition;
\r
46 include.SourceUri = reader.BaseURI;
\r
48 while(reader.MoveToNextAttribute())
\r
50 if(reader.Name == "id")
\r
52 include.Id = reader.Value;
\r
54 else if(reader.Name == "schemaLocation")
\r
56 include.SchemaLocation = reader.Value;
\r
58 else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
\r
60 error(h,reader.Name + " is not a valid attribute for include",null);
\r
64 if(reader.Prefix == "xmlns")
\r
65 include.Namespaces.Add(reader.LocalName, reader.Value);
\r
66 else if(reader.Name == "xmlns")
\r
67 include.Namespaces.Add("",reader.Value);
\r
68 //TODO: Add to Unhandled attributes
\r
72 reader.MoveToElement();
\r
73 if(reader.IsEmptyElement)
\r
76 // Content: (annotation?)
\r
78 while(reader.ReadNextElement())
\r
80 if(reader.NodeType == XmlNodeType.EndElement)
\r
82 if(reader.LocalName != xmlname)
\r
83 error(h,"Should not happen :2: XmlSchemaInclude.Read, name="+reader.Name,null);
\r
86 if(level <= 1 && reader.LocalName == "annotation")
\r
88 level = 2; //Only one annotation
\r
89 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
\r
90 if(annotation != null)
\r
91 include.Annotation = annotation;
\r
94 reader.RaiseInvalidElementError();
\r