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
38 internal override int Compile(ValidationEventHandler h, XmlSchema schema)
\r
40 // If this is already compiled this time, simply skip.
\r
41 if (this.IsComplied (schema.CompilationId))
\r
45 if(RefName == null || RefName.IsEmpty)
\r
46 error(h, "ref must be present");
\r
47 else if(!XmlSchemaUtil.CheckQName(RefName))
\r
48 error(h, "ref must be a valid qname");
\r
50 XmlSchemaUtil.CompileID(Id,this, schema.IDCollection,h);
\r
52 // if(this.Annotation != null)
\r
53 // error(h, "attributegroup with a ref can't have any content");
\r
55 this.CompilationId = schema.CompilationId;
\r
59 internal override int Validate(ValidationEventHandler h, XmlSchema schema)
\r
67 // {any attributes with non-schema namespace . . .}>
\r
68 // Content: (annotation?)
\r
70 internal static XmlSchemaAttributeGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
72 XmlSchemaAttributeGroupRef attrgrp = new XmlSchemaAttributeGroupRef();
\r
73 reader.MoveToElement();
\r
75 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
\r
77 error(h,"Should not happen :1: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);
\r
82 attrgrp.LineNumber = reader.LineNumber;
\r
83 attrgrp.LinePosition = reader.LinePosition;
\r
84 attrgrp.SourceUri = reader.BaseURI;
\r
86 while(reader.MoveToNextAttribute())
\r
88 if(reader.Name == "id")
\r
90 attrgrp.Id = reader.Value;
\r
92 else if(reader.Name == "ref")
\r
95 attrgrp.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
\r
97 error(h, reader.Value + " is not a valid value for ref attribute",innerex);
\r
99 else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
\r
101 error(h,reader.Name + " is not a valid attribute for attributeGroup in this context",null);
\r
105 XmlSchemaUtil.ReadUnhandledAttribute(reader,attrgrp);
\r
109 reader.MoveToElement();
\r
110 if(reader.IsEmptyElement)
\r
114 while(reader.ReadNextElement())
\r
116 if(reader.NodeType == XmlNodeType.EndElement)
\r
118 if(reader.LocalName != xmlname)
\r
119 error(h,"Should not happen :2: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);
\r
122 if(level <= 1 && reader.LocalName == "annotation")
\r
124 level = 2; //Only one annotation
\r
125 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
\r
126 if(annotation != null)
\r
127 attrgrp.Annotation = annotation;
\r
130 reader.RaiseInvalidElementError();
\r