update this directory to include the handle branch changes, as well as the SendParent...
[mono-project.git] / mcs / class / System.XML / System.Xml.Schema / XmlSchemaInclude.cs
blob6773a5f3dd1969bb73fc15993f177c3cd42a9237
1 // Author: Dwivedi, Ajay kumar
2 // Adwiv@Yahoo.com
4 //
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:
12 //
13 // The above copyright notice and this permission notice shall be
14 // included in all copies or substantial portions of the Software.
15 //
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.
24 using System;
25 using System.Xml.Serialization;
26 using System.Xml;
28 namespace System.Xml.Schema
30 /// <summary>
31 /// Summary description for XmlSchemaInclude.
32 /// </summary>
33 public class XmlSchemaInclude : XmlSchemaExternal
35 private XmlSchemaAnnotation annotation;
36 const string xmlname = "include";
38 public XmlSchemaInclude()
41 [XmlElement("annotation", Type=typeof (XmlSchemaAnnotation))]
42 public XmlSchemaAnnotation Annotation
44 get{ return annotation; }
45 set{ annotation = value; }
48 //<include
49 // id = ID
50 // schemaLocation = anyURI
51 // {any attributes with non-schema namespace . . .}>
52 // Content: (annotation?)
53 //</include>
54 internal static XmlSchemaInclude Read(XmlSchemaReader reader, ValidationEventHandler h)
56 XmlSchemaInclude include = new XmlSchemaInclude();
57 reader.MoveToElement();
59 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
61 error(h,"Should not happen :1: XmlSchemaInclude.Read, name="+reader.Name,null);
62 reader.SkipToEnd();
63 return null;
66 include.LineNumber = reader.LineNumber;
67 include.LinePosition = reader.LinePosition;
68 include.SourceUri = reader.BaseURI;
70 while(reader.MoveToNextAttribute())
72 if(reader.Name == "id")
74 include.Id = reader.Value;
76 else if(reader.Name == "schemaLocation")
78 include.SchemaLocation = reader.Value;
80 else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
82 error(h,reader.Name + " is not a valid attribute for include",null);
84 else
86 XmlSchemaUtil.ReadUnhandledAttribute(reader,include);
90 reader.MoveToElement();
91 if(reader.IsEmptyElement)
92 return include;
94 // Content: (annotation?)
95 int level = 1;
96 while(reader.ReadNextElement())
98 if(reader.NodeType == XmlNodeType.EndElement)
100 if(reader.LocalName != xmlname)
101 error(h,"Should not happen :2: XmlSchemaInclude.Read, name="+reader.Name,null);
102 break;
104 if(level <= 1 && reader.LocalName == "annotation")
106 level = 2; //Only one annotation
107 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
108 if(annotation != null)
109 include.Annotation = annotation;
110 continue;
112 reader.RaiseInvalidElementError();
115 return include;