1 // Author: Dwivedi, Ajay kumar
\r
6 namespace System.Xml.Schema
\r
9 /// Summary description for XmlSchemaMaxLengthFacet.
\r
11 public class XmlSchemaMaxLengthFacet : XmlSchemaNumericFacet
\r
13 private static string xmlname = "maxLength";
\r
15 public XmlSchemaMaxLengthFacet()
\r
20 // fixed = boolean : false
\r
22 // value = nonNegativeInteger
\r
23 // {any attributes with non-schema namespace . . .}>
\r
24 // Content: (annotation?)
\r
26 internal static XmlSchemaMaxLengthFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
28 XmlSchemaMaxLengthFacet length = new XmlSchemaMaxLengthFacet();
\r
29 reader.MoveToElement();
\r
31 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
\r
33 error(h,"Should not happen :1: XmlSchemaMaxLengthFacet.Read, name="+reader.Name,null);
\r
38 length.LineNumber = reader.LineNumber;
\r
39 length.LinePosition = reader.LinePosition;
\r
40 length.SourceUri = reader.BaseURI;
\r
42 while(reader.MoveToNextAttribute())
\r
44 if(reader.Name == "id")
\r
46 length.Id = reader.Value;
\r
48 else if(reader.Name == "fixed")
\r
51 length.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
\r
53 error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
\r
55 else if(reader.Name == "value")
\r
57 length.Value = reader.Value;
\r
59 else if(reader.NamespaceURI == "" || reader.NamespaceURI == XmlSchema.Namespace)
\r
61 error(h,reader.Name + " is not a valid attribute for group",null);
\r
65 if(reader.Prefix == "xmlns")
\r
66 length.Namespaces.Add(reader.LocalName, reader.Value);
\r
67 else if(reader.Name == "xmlns")
\r
68 length.Namespaces.Add("",reader.Value);
\r
69 //TODO: Add to Unhandled attributes
\r
73 reader.MoveToElement();
\r
74 if(reader.IsEmptyElement)
\r
77 // Content: (annotation?)
\r
79 while(reader.ReadNextElement())
\r
81 if(reader.NodeType == XmlNodeType.EndElement)
\r
83 if(reader.LocalName != xmlname)
\r
84 error(h,"Should not happen :2: XmlSchemaMaxLengthFacet.Read, name="+reader.Name,null);
\r
87 if(level <= 1 && reader.LocalName == "annotation")
\r
89 level = 2; //Only one annotation
\r
90 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
\r
91 if(annotation != null)
\r
92 length.Annotation = annotation;
\r
95 reader.RaiseInvalidElementError();
\r