1 // Author: Dwivedi, Ajay kumar
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
;
28 namespace System
.Xml
.Schema
31 /// Summary description for XmlSchemaInclude.
33 public class XmlSchemaInclude
: XmlSchemaExternal
35 private XmlSchemaAnnotation annotation
;
36 const string xmlname
= "include";
38 public XmlSchemaInclude()
41 [XmlElement("annotation",Namespace
=XmlSchema
.Namespace
)]
42 public XmlSchemaAnnotation Annotation
44 get{ return annotation; }
45 set{ annotation = value; }
50 // schemaLocation = anyURI
51 // {any attributes with non-schema namespace . . .}>
52 // Content: (annotation?)
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);
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);
86 XmlSchemaUtil
.ReadUnhandledAttribute(reader
,include
);
90 reader
.MoveToElement();
91 if(reader
.IsEmptyElement
)
94 // Content: (annotation?)
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);
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
;
112 reader
.RaiseInvalidElementError();