1 // Author: Dwivedi, Ajay kumar
5 // Permission is hereby granted, free of charge, to any person obtaining
6 // a copy of this software and associated documentation files (the
7 // "Software"), to deal in the Software without restriction, including
8 // without limitation the rights to use, copy, modify, merge, publish,
9 // distribute, sublicense, and/or sell copies of the Software, and to
10 // permit persons to whom the Software is furnished to do so, subject to
11 // the following conditions:
13 // The above copyright notice and this permission notice shall be
14 // included in all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 namespace System
.Xml
.Schema
30 /// Summary description for XmlSchemaTotalDigitsFacet.
32 public class XmlSchemaTotalDigitsFacet
: XmlSchemaNumericFacet
34 const string xmlname
= "totalDigits";
36 public XmlSchemaTotalDigitsFacet()
40 internal override Facet ThisFacet
{
41 get { return Facet.totalDigits;}
45 // fixed = boolean : false
47 // value = positiveInteger
48 // {any attributes with non-schema namespace . . .}>
49 // Content: (annotation?)
51 internal static XmlSchemaTotalDigitsFacet
Read(XmlSchemaReader reader
, ValidationEventHandler h
)
53 XmlSchemaTotalDigitsFacet td
= new XmlSchemaTotalDigitsFacet();
54 reader
.MoveToElement();
56 if(reader
.NamespaceURI
!= XmlSchema
.Namespace
|| reader
.LocalName
!= xmlname
)
58 error(h
,"Should not happen :1: XmlSchemaTotalDigitsFacet.Read, name="+reader
.Name
,null);
63 td
.LineNumber
= reader
.LineNumber
;
64 td
.LinePosition
= reader
.LinePosition
;
65 td
.SourceUri
= reader
.BaseURI
;
67 while(reader
.MoveToNextAttribute())
69 if(reader
.Name
== "id")
73 else if(reader
.Name
== "fixed")
76 td
.IsFixed
= XmlSchemaUtil
.ReadBoolAttribute(reader
,out innerex
);
78 error(h
, reader
.Value
+ " is not a valid value for fixed attribute",innerex
);
80 else if(reader
.Name
== "value")
82 td
.Value
= reader
.Value
;
84 else if((reader
.NamespaceURI
== "" && reader
.Name
!= "xmlns") || reader
.NamespaceURI
== XmlSchema
.Namespace
)
86 error(h
,reader
.Name
+ " is not a valid attribute for "+xmlname
,null);
90 XmlSchemaUtil
.ReadUnhandledAttribute(reader
,td
);
94 reader
.MoveToElement();
95 if(reader
.IsEmptyElement
)
98 // Content: (annotation?)
100 while(reader
.ReadNextElement())
102 if(reader
.NodeType
== XmlNodeType
.EndElement
)
104 if(reader
.LocalName
!= xmlname
)
105 error(h
,"Should not happen :2: XmlSchemaTotalDigitsFacet.Read, name="+reader
.Name
,null);
108 if(level
<= 1 && reader
.LocalName
== "annotation")
110 level
= 2; //Only one annotation
111 XmlSchemaAnnotation annotation
= XmlSchemaAnnotation
.Read(reader
,h
);
112 if(annotation
!= null)
113 td
.Annotation
= annotation
;
116 reader
.RaiseInvalidElementError();