1 // Author: Dwivedi, Ajay kumar
\r
5 using System.Xml.Serialization;
\r
7 namespace System.Xml.Schema
\r
10 /// Summary description for XmlSchemaSimpleContentRestriction.
\r
12 public class XmlSchemaSimpleContentRestriction : XmlSchemaContent
\r
15 private XmlSchemaAnyAttribute any;
\r
16 private XmlSchemaObjectCollection attributes;
\r
17 private XmlSchemaSimpleType baseType;
\r
18 private XmlQualifiedName baseTypeName;
\r
19 private XmlSchemaObjectCollection facets;
\r
20 private int errorCount=0;
\r
22 public XmlSchemaSimpleContentRestriction()
\r
24 baseTypeName = XmlQualifiedName.Empty;
\r
25 attributes = new XmlSchemaObjectCollection();
\r
26 facets = new XmlSchemaObjectCollection();
\r
29 [System.Xml.Serialization.XmlAttribute("base")]
\r
30 public XmlQualifiedName BaseTypeName
\r
32 get{ return baseTypeName; }
\r
33 set{ baseTypeName = value; }
\r
36 [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
\r
37 public XmlSchemaAnyAttribute AnyAttribute
\r
43 [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
44 [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
45 public XmlSchemaObjectCollection Attributes
\r
47 get{ return attributes; }
\r
50 [XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
\r
51 public XmlSchemaSimpleType BaseType
\r
53 get{ return baseType; }
\r
54 set{ baseType = value; }
\r
58 [XmlElement("minExclusive",typeof(XmlSchemaMinExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
59 [XmlElement("minInclusive",typeof(XmlSchemaMinInclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
60 [XmlElement("maxExclusive",typeof(XmlSchemaMaxExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
61 [XmlElement("maxInclusive",typeof(XmlSchemaMaxInclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
62 [XmlElement("totalDigits",typeof(XmlSchemaTotalDigitsFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
63 [XmlElement("fractionDigits",typeof(XmlSchemaFractionDigitsFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
64 [XmlElement("length",typeof(XmlSchemaLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
65 [XmlElement("minLength",typeof(XmlSchemaMinLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
66 [XmlElement("maxLength",typeof(XmlSchemaMaxLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
67 [XmlElement("enumeration",typeof(XmlSchemaEnumerationFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
68 [XmlElement("whiteSpace",typeof(XmlSchemaWhiteSpaceFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
69 [XmlElement("pattern",typeof(XmlSchemaPatternFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
\r
70 public XmlSchemaObjectCollection Facets
\r
72 get{ return facets; }
\r
75 /// 1. Base must be present and a QName
\r
78 internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
\r
80 if(BaseTypeName == null || BaseTypeName.IsEmpty)
\r
82 error(h, "base must be present and a QName");
\r
85 if(BaseType != null)
\r
87 errorCount += BaseType.Compile(h,info);
\r
90 if(this.AnyAttribute != null)
\r
92 errorCount += AnyAttribute.Compile(h,info);
\r
95 foreach(XmlSchemaObject obj in Attributes)
\r
97 if(obj is XmlSchemaAttribute)
\r
99 XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
\r
100 errorCount += attr.Compile(h,info);
\r
102 else if(obj is XmlSchemaAttributeGroupRef)
\r
104 XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;
\r
105 errorCount += atgrp.Compile(h,info);
\r
108 error(h,"object is not valid in this place");
\r
111 //TODO: Compile Facets: Looks like they are a part of datatypes. So we'll do them with the datatypes
\r
113 if(this.Id != null && !XmlSchemaUtil.CheckID(Id))
\r
114 error(h, "id must be a valid ID");
\r
119 internal int Validate(ValidationEventHandler h)
\r
124 internal void error(ValidationEventHandler handle,string message)
\r
127 ValidationHandler.RaiseValidationError(handle,this,message);
\r