(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.XML / System.Xml.Schema / XmlSchemaAttributeGroupRef.cs
blobc9fb14255b24753e07816934658f900beffd5c04
1 //
2 // System.Xml.Schema.XmlSchemaAttributeGroupRef.cs
3 //
4 // Author:
5 // Dwivedi, Ajay kumar Adwiv@Yahoo.com
6 // Atsushi Enomoto ginga@kit.hi-ho.ne.jp
7 //
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System;
30 using System.Xml;
31 using System.Xml.Serialization;
33 namespace System.Xml.Schema
35 /// <summary>
36 /// Summary description for XmlSchemaAttributeGroupRef.
37 /// </summary>
38 public class XmlSchemaAttributeGroupRef : XmlSchemaAnnotated
40 private XmlQualifiedName refName;
41 const string xmlname = "attributeGroup";
43 public XmlSchemaAttributeGroupRef()
45 refName = XmlQualifiedName.Empty;
48 [System.Xml.Serialization.XmlAttribute("ref")]
49 public XmlQualifiedName RefName
51 get{ return refName; }
52 set{ refName = value; }
55 /// <remarks>
56 /// 1. ref must be present
57 /// </remarks>
58 internal override int Compile(ValidationEventHandler h, XmlSchema schema)
60 // If this is already compiled this time, simply skip.
61 if (this.IsComplied (schema.CompilationId))
62 return 0;
64 errorCount = 0;
65 if(RefName == null || RefName.IsEmpty)
66 error(h, "ref must be present");
67 else if(!XmlSchemaUtil.CheckQName(RefName))
68 error(h, "ref must be a valid qname");
70 XmlSchemaUtil.CompileID(Id,this, schema.IDCollection,h);
72 this.CompilationId = schema.CompilationId;
73 return errorCount;
76 internal override int Validate(ValidationEventHandler h, XmlSchema schema)
78 return errorCount;
81 //<attributeGroup
82 // id = ID
83 // ref = QName
84 // {any attributes with non-schema namespace . . .}>
85 // Content: (annotation?)
86 //</attributeGroup>
87 internal static XmlSchemaAttributeGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h)
89 XmlSchemaAttributeGroupRef attrgrp = new XmlSchemaAttributeGroupRef();
90 reader.MoveToElement();
92 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
94 error(h,"Should not happen :1: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);
95 reader.SkipToEnd();
96 return null;
99 attrgrp.LineNumber = reader.LineNumber;
100 attrgrp.LinePosition = reader.LinePosition;
101 attrgrp.SourceUri = reader.BaseURI;
103 while(reader.MoveToNextAttribute())
105 if(reader.Name == "id")
107 attrgrp.Id = reader.Value;
109 else if(reader.Name == "ref")
111 Exception innerex;
112 attrgrp.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
113 if(innerex != null)
114 error(h, reader.Value + " is not a valid value for ref attribute",innerex);
116 else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
118 error(h,reader.Name + " is not a valid attribute for attributeGroup in this context",null);
120 else
122 XmlSchemaUtil.ReadUnhandledAttribute(reader,attrgrp);
126 reader.MoveToElement();
127 if(reader.IsEmptyElement)
128 return attrgrp;
129 int level = 1;
131 while(reader.ReadNextElement())
133 if(reader.NodeType == XmlNodeType.EndElement)
135 if(reader.LocalName != xmlname)
136 error(h,"Should not happen :2: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);
137 break;
139 if(level <= 1 && reader.LocalName == "annotation")
141 level = 2; //Only one annotation
142 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
143 if(annotation != null)
144 attrgrp.Annotation = annotation;
145 continue;
147 reader.RaiseInvalidElementError();
149 return attrgrp;