2 // System.Xml.Schema.XmlSchemaAttributeGroupRef.cs
\r
5 // Dwivedi, Ajay kumar Adwiv@Yahoo.com
\r
6 // Atsushi Enomoto ginga@kit.hi-ho.ne.jp
\r
10 using System.Xml.Serialization;
\r
12 namespace System.Xml.Schema
\r
15 /// Summary description for XmlSchemaAttributeGroupRef.
\r
17 public class XmlSchemaAttributeGroupRef : XmlSchemaAnnotated
\r
19 private XmlQualifiedName refName;
\r
20 private static string xmlname = "attributeGroup";
\r
22 public XmlSchemaAttributeGroupRef()
\r
24 refName = XmlQualifiedName.Empty;
\r
27 [System.Xml.Serialization.XmlAttribute("ref")]
\r
28 public XmlQualifiedName RefName
\r
30 get{ return refName; }
\r
31 set{ refName = value; }
\r
35 /// 1. ref must be present
\r
36 /// 2. The element must be empty. ?? FIXME: Is this correct or annotation is permitted?
\r
39 internal override int Compile(ValidationEventHandler h, XmlSchema schema)
\r
41 // If this is already compiled this time, simply skip.
\r
42 if (this.IsComplied (schema.CompilationId))
\r
46 if(RefName == null || RefName.IsEmpty)
\r
47 error(h, "ref must be present");
\r
48 else if(!XmlSchemaUtil.CheckQName(RefName))
\r
49 error(h, "ref must be a valid qname");
\r
51 XmlSchemaUtil.CompileID(Id,this, schema.IDCollection,h);
\r
53 // if(this.Annotation != null)
\r
54 // error(h, "attributegroup with a ref can't have any content");
\r
56 this.CompilationId = schema.CompilationId;
\r
61 internal override int Validate(ValidationEventHandler h, XmlSchema schema)
\r
69 // {any attributes with non-schema namespace . . .}>
\r
70 // Content: (annotation?)
\r
72 internal static XmlSchemaAttributeGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
74 XmlSchemaAttributeGroupRef attrgrp = new XmlSchemaAttributeGroupRef();
\r
75 reader.MoveToElement();
\r
77 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
\r
79 error(h,"Should not happen :1: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);
\r
84 attrgrp.LineNumber = reader.LineNumber;
\r
85 attrgrp.LinePosition = reader.LinePosition;
\r
86 attrgrp.SourceUri = reader.BaseURI;
\r
88 while(reader.MoveToNextAttribute())
\r
90 if(reader.Name == "id")
\r
92 attrgrp.Id = reader.Value;
\r
94 else if(reader.Name == "ref")
\r
97 attrgrp.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
\r
99 error(h, reader.Value + " is not a valid value for ref attribute",innerex);
\r
101 else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
\r
103 error(h,reader.Name + " is not a valid attribute for attributeGroup in this context",null);
\r
107 XmlSchemaUtil.ReadUnhandledAttribute(reader,attrgrp);
\r
111 reader.MoveToElement();
\r
112 if(reader.IsEmptyElement)
\r
116 while(reader.ReadNextElement())
\r
118 if(reader.NodeType == XmlNodeType.EndElement)
\r
120 if(reader.LocalName != xmlname)
\r
121 error(h,"Should not happen :2: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);
\r
124 if(level <= 1 && reader.LocalName == "annotation")
\r
126 level = 2; //Only one annotation
\r
127 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
\r
128 if(annotation != null)
\r
129 attrgrp.Annotation = annotation;
\r
132 reader.RaiseInvalidElementError();
\r