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 XmlSchemaInclude.
\r
33 public class XmlSchemaInclude : XmlSchemaExternal
\r
35 private XmlSchemaAnnotation annotation;
\r
36 const string xmlname = "include";
\r
38 public XmlSchemaInclude()
\r
41 [XmlElement("annotation",Namespace=XmlSchema.Namespace)]
\r
42 public XmlSchemaAnnotation Annotation
\r
44 get{ return annotation; }
\r
45 set{ annotation = value; }
\r
50 // schemaLocation = anyURI
\r
51 // {any attributes with non-schema namespace . . .}>
\r
52 // Content: (annotation?)
\r
54 internal static XmlSchemaInclude Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
56 XmlSchemaInclude include = new XmlSchemaInclude();
\r
57 reader.MoveToElement();
\r
59 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
\r
61 error(h,"Should not happen :1: XmlSchemaInclude.Read, name="+reader.Name,null);
\r
66 include.LineNumber = reader.LineNumber;
\r
67 include.LinePosition = reader.LinePosition;
\r
68 include.SourceUri = reader.BaseURI;
\r
70 while(reader.MoveToNextAttribute())
\r
72 if(reader.Name == "id")
\r
74 include.Id = reader.Value;
\r
76 else if(reader.Name == "schemaLocation")
\r
78 include.SchemaLocation = reader.Value;
\r
80 else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
\r
82 error(h,reader.Name + " is not a valid attribute for include",null);
\r
86 XmlSchemaUtil.ReadUnhandledAttribute(reader,include);
\r
90 reader.MoveToElement();
\r
91 if(reader.IsEmptyElement)
\r
94 // Content: (annotation?)
\r
96 while(reader.ReadNextElement())
\r
98 if(reader.NodeType == XmlNodeType.EndElement)
\r
100 if(reader.LocalName != xmlname)
\r
101 error(h,"Should not happen :2: XmlSchemaInclude.Read, name="+reader.Name,null);
\r
104 if(level <= 1 && reader.LocalName == "annotation")
\r
106 level = 2; //Only one annotation
\r
107 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
\r
108 if(annotation != null)
\r
109 include.Annotation = annotation;
\r
112 reader.RaiseInvalidElementError();
\r