1 // Author: Dwivedi, Ajay kumar
\r
6 namespace System.Xml.Schema
\r
9 /// Summary description for XmlSchemaMinLengthFacet.
\r
11 public class XmlSchemaMinLengthFacet : XmlSchemaNumericFacet
\r
13 const string xmlname = "minLength";
\r
15 public XmlSchemaMinLengthFacet()
\r
19 internal override Facet ThisFacet {
\r
20 get { return Facet.minLength;}
\r
25 // fixed = boolean : false
\r
27 // value = nonNegativeInteger
\r
28 // {any attributes with non-schema namespace . . .}>
\r
29 // Content: (annotation?)
\r
31 internal static XmlSchemaMinLengthFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
33 XmlSchemaMinLengthFacet length = new XmlSchemaMinLengthFacet();
\r
34 reader.MoveToElement();
\r
36 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
\r
38 error(h,"Should not happen :1: XmlSchemaMinLengthFacet.Read, name="+reader.Name,null);
\r
43 length.LineNumber = reader.LineNumber;
\r
44 length.LinePosition = reader.LinePosition;
\r
45 length.SourceUri = reader.BaseURI;
\r
47 while(reader.MoveToNextAttribute())
\r
49 if(reader.Name == "id")
\r
51 length.Id = reader.Value;
\r
53 else if(reader.Name == "fixed")
\r
56 length.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
\r
58 error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
\r
60 else if(reader.Name == "value")
\r
62 length.Value = reader.Value;
\r
64 else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
\r
66 error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
\r
70 XmlSchemaUtil.ReadUnhandledAttribute(reader,length);
\r
74 reader.MoveToElement();
\r
75 if(reader.IsEmptyElement)
\r
78 // Content: (annotation?)
\r
80 while(reader.ReadNextElement())
\r
82 if(reader.NodeType == XmlNodeType.EndElement)
\r
84 if(reader.LocalName != xmlname)
\r
85 error(h,"Should not happen :2: XmlSchemaMinLengthFacet.Read, name="+reader.Name,null);
\r
88 if(level <= 1 && reader.LocalName == "annotation")
\r
90 level = 2; //Only one annotation
\r
91 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
\r
92 if(annotation != null)
\r
93 length.Annotation = annotation;
\r
96 reader.RaiseInvalidElementError();
\r