2008-12-08 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System.XML / System.Xml.Schema / XmlSchemaAttributeGroupRef.cs
index b3715b0cccf6621cb3d8506f585c32356461f297..34888be0c229d65c4bb3ca8e3f8821c97ec4c1ca 100644 (file)
@@ -1,10 +1,10 @@
-//\r
-// System.Xml.Schema.XmlSchemaAttributeGroupRef.cs\r
-//\r
-// Author:\r
-//     Dwivedi, Ajay kumar  Adwiv@Yahoo.com\r
-//     Atsushi Enomoto  ginga@kit.hi-ho.ne.jp\r
-//\r
+//
+// System.Xml.Schema.XmlSchemaAttributeGroupRef.cs
+//
+// Author:
+//     Dwivedi, Ajay kumar  Adwiv@Yahoo.com
+//     Atsushi Enomoto  ginga@kit.hi-ho.ne.jp
+//
 
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-using System;\r
-using System.Xml;\r
-using System.Xml.Serialization;\r
-\r
-namespace System.Xml.Schema\r
-{\r
-       /// <summary>\r
-       /// Summary description for XmlSchemaAttributeGroupRef.\r
-       /// </summary>\r
-       public class XmlSchemaAttributeGroupRef : XmlSchemaAnnotated\r
-       {\r
-               private XmlQualifiedName refName;\r
-               const string xmlname = "attributeGroup";\r
-\r
-               public XmlSchemaAttributeGroupRef()\r
-               {\r
-                       refName = XmlQualifiedName.Empty;\r
-               }\r
-               \r
-               [System.Xml.Serialization.XmlAttribute("ref")]\r
-               public XmlQualifiedName RefName \r
-               {\r
-                       get{ return  refName; }\r
-                       set{ refName = value; }\r
-               }\r
-\r
-               /// <remarks>\r
-               /// 1. ref must be present\r
-               /// </remarks>\r
-               internal override int Compile(ValidationEventHandler h, XmlSchema schema)\r
-               {\r
-                       // If this is already compiled this time, simply skip.\r
-                       if (CompilationId == schema.CompilationId)\r
-                               return 0;\r
-\r
-                       errorCount = 0;\r
-                       if(RefName == null || RefName.IsEmpty)\r
-                               error(h, "ref must be present");\r
-                       else if(!XmlSchemaUtil.CheckQName(RefName))\r
-                               error(h, "ref must be a valid qname");\r
-\r
-                       XmlSchemaUtil.CompileID(Id,this, schema.IDCollection,h);\r
-\r
-                       this.CompilationId = schema.CompilationId;\r
-                       return errorCount;\r
-               }\r
-               \r
-               internal override int Validate(ValidationEventHandler h, XmlSchema schema)\r
-               {\r
-                       return errorCount;\r
-               }\r
-\r
-               //<attributeGroup\r
-               //  id = ID\r
-               //  ref = QName\r
-               //  {any attributes with non-schema namespace . . .}>\r
-               //  Content: (annotation?)\r
-               //</attributeGroup>\r
-               internal static XmlSchemaAttributeGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h)\r
-               {\r
-                       XmlSchemaAttributeGroupRef attrgrp = new XmlSchemaAttributeGroupRef();\r
-                       reader.MoveToElement();\r
-\r
-                       if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)\r
-                       {\r
-                               error(h,"Should not happen :1: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);\r
-                               reader.SkipToEnd();\r
-                               return null;\r
-                       }\r
-\r
-                       attrgrp.LineNumber = reader.LineNumber;\r
-                       attrgrp.LinePosition = reader.LinePosition;\r
-                       attrgrp.SourceUri = reader.BaseURI;\r
-\r
-                       while(reader.MoveToNextAttribute())\r
-                       {\r
-                               if(reader.Name == "id")\r
-                               {\r
-                                       attrgrp.Id = reader.Value;\r
-                               }\r
-                               else if(reader.Name == "ref")\r
-                               {\r
-                                       Exception innerex;\r
-                                       attrgrp.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);\r
-                                       if(innerex != null)\r
-                                               error(h, reader.Value + " is not a valid value for ref attribute",innerex);\r
-                               }\r
-                               else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)\r
-                               {\r
-                                       error(h,reader.Name + " is not a valid attribute for attributeGroup in this context",null);\r
-                               }\r
-                               else\r
-                               {\r
-                                       XmlSchemaUtil.ReadUnhandledAttribute(reader,attrgrp);\r
-                               }\r
-                       }\r
-                       \r
-                       reader.MoveToElement();\r
-                       if(reader.IsEmptyElement)\r
-                               return attrgrp;\r
-                       int level = 1;\r
-\r
-                       while(reader.ReadNextElement())\r
-                       {\r
-                               if(reader.NodeType == XmlNodeType.EndElement)\r
-                               {\r
-                                       if(reader.LocalName != xmlname)\r
-                                               error(h,"Should not happen :2: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);\r
-                                       break;\r
-                               }\r
-                               if(level <= 1 && reader.LocalName == "annotation")\r
-                               {\r
-                                       level = 2; //Only one annotation\r
-                                       XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);\r
-                                       if(annotation != null)\r
-                                               attrgrp.Annotation = annotation;\r
-                                       continue;\r
-                               }\r
-                               reader.RaiseInvalidElementError();\r
-                       }\r
-                       return attrgrp;\r
-               }\r
-       }\r
-}\r
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+       /// <summary>
+       /// Summary description for XmlSchemaAttributeGroupRef.
+       /// </summary>
+       public class XmlSchemaAttributeGroupRef : XmlSchemaAnnotated
+       {
+               private XmlQualifiedName refName;
+               const string xmlname = "attributeGroup";
+
+               public XmlSchemaAttributeGroupRef()
+               {
+                       refName = XmlQualifiedName.Empty;
+               }
+               
+               [System.Xml.Serialization.XmlAttribute("ref")]
+               public XmlQualifiedName RefName 
+               {
+                       get{ return  refName; }
+                       set{ refName = value; }
+               }
+
+               /// <remarks>
+               /// 1. ref must be present
+               /// </remarks>
+               internal override int Compile(ValidationEventHandler h, XmlSchema schema)
+               {
+                       // If this is already compiled this time, simply skip.
+                       if (CompilationId == schema.CompilationId)
+                               return 0;
+
+                       errorCount = 0;
+                       if(RefName == null || RefName.IsEmpty)
+                               error(h, "ref must be present");
+                       else if(!XmlSchemaUtil.CheckQName(RefName))
+                               error(h, "ref must be a valid qname");
+
+                       XmlSchemaUtil.CompileID(Id,this, schema.IDCollection,h);
+
+                       this.CompilationId = schema.CompilationId;
+                       return errorCount;
+               }
+               
+               internal override int Validate(ValidationEventHandler h, XmlSchema schema)
+               {
+                       return errorCount;
+               }
+
+               //<attributeGroup
+               //  id = ID
+               //  ref = QName
+               //  {any attributes with non-schema namespace . . .}>
+               //  Content: (annotation?)
+               //</attributeGroup>
+               internal static XmlSchemaAttributeGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h)
+               {
+                       XmlSchemaAttributeGroupRef attrgrp = new XmlSchemaAttributeGroupRef();
+                       reader.MoveToElement();
+
+                       if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+                       {
+                               error(h,"Should not happen :1: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);
+                               reader.SkipToEnd();
+                               return null;
+                       }
+
+                       attrgrp.LineNumber = reader.LineNumber;
+                       attrgrp.LinePosition = reader.LinePosition;
+                       attrgrp.SourceUri = reader.BaseURI;
+
+                       while(reader.MoveToNextAttribute())
+                       {
+                               if(reader.Name == "id")
+                               {
+                                       attrgrp.Id = reader.Value;
+                               }
+                               else if(reader.Name == "ref")
+                               {
+                                       Exception innerex;
+                                       attrgrp.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+                                       if(innerex != null)
+                                               error(h, reader.Value + " is not a valid value for ref attribute",innerex);
+                               }
+                               else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+                               {
+                                       error(h,reader.Name + " is not a valid attribute for attributeGroup in this context",null);
+                               }
+                               else
+                               {
+                                       XmlSchemaUtil.ReadUnhandledAttribute(reader,attrgrp);
+                               }
+                       }
+                       
+                       reader.MoveToElement();
+                       if(reader.IsEmptyElement)
+                               return attrgrp;
+                       int level = 1;
+
+                       while(reader.ReadNextElement())
+                       {
+                               if(reader.NodeType == XmlNodeType.EndElement)
+                               {
+                                       if(reader.LocalName != xmlname)
+                                               error(h,"Should not happen :2: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);
+                                       break;
+                               }
+                               if(level <= 1 && reader.LocalName == "annotation")
+                               {
+                                       level = 2; //Only one annotation
+                                       XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+                                       if(annotation != null)
+                                               attrgrp.Annotation = annotation;
+                                       continue;
+                               }
+                               reader.RaiseInvalidElementError();
+                       }
+                       return attrgrp;
+               }
+       }
+}