1 {
2   Parser functions to parser xml xsd types
3   See: http://books.xmlschemata.org/relaxng/relax-CHP-19.html
4 
5   Copyright (C) 2011 by Ivo Steinmann
6 }
7 
8 unit xmlxsdparser;
9 
10 {$mode objfpc}
11 {$H+}
12 
13 interface
14 
15 uses
16   {$IFDEF MSWINDOWS}windows,{$ENDIF}
17   {$IFDEF UNIX}unixutil,{$ENDIF}
18   sysutils,
19   dateutils,
20   math,
21   Classes;
22 
23 resourcestring
24   SXsdParserError = 'parsing "%s" as "%s" failed';
25 
26 type
27 {$IFDEF MSWINDOWS}
28   PBoolean = System.PBoolean;
29   // PBoolean is redefined by windows unit, so redefine it here again!
30 {$ENDIF}
31 
32   TXsdTimezoneType = (
33     tzUnknown,
34     tzLocal,
35     tzUtc
36   );
37 
38   PXsdTimezone = ^TXsdTimezone;
39   TXsdTimezone = record
40     Kind   : TXsdTimezoneType;
41     Hour   : Longint;  // +/- [00..23]
42     Minute : Longword; // [00..59]
43   end;
44 
45 const
46   TIMEZONE_UTC: TXsdTimezone = (Kind:tzUTC;Hour:0;Minute:0);
47 
48 
49 { Format functions }
xsdFormatBase64null50 function xsdFormatBase64(Value: TStream): AnsiString;
xsdFormatBooleannull51 function xsdFormatBoolean(Value: Boolean; UseWords: Boolean = False): AnsiString;
xsdFormatDatenull52 function xsdFormatDate(Year, Month, Day: Longword; BC: Boolean; Timezone: PXsdTimezone = nil): AnsiString;
xsdFormatDatenull53 function xsdFormatDate(Value: TDateTime; Timezone: PXsdTimezone = nil): AnsiString;
xsdFormatTimenull54 function xsdFormatTime(Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil): AnsiString;
xsdFormatTimenull55 function xsdFormatTime(Value: TDateTime; Timezone: PXsdTimezone = nil): AnsiString;
xsdFormatDateTimenull56 function xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; BC: Boolean; Timezone: PXsdTimezone = nil): AnsiString;
xsdFormatDateTimenull57 function xsdFormatDateTime(Value: TDateTime; Timezone: PXsdTimezone): AnsiString;
xsdFormatDecimalnull58 function xsdFormatDecimal(Value: Extended; Precision: Integer = 4; Digits: Integer = 1): AnsiString;
xsdFormatDoublenull59 function xsdFormatDouble(Value: Double): AnsiString;
xsdFormatFloatnull60 function xsdFormatFloat(Value: Single): AnsiString;
xsdFormatBytenull61 function xsdFormatByte(Value: Shortint): AnsiString;
xsdFormatShortnull62 function xsdFormatShort(Value: Smallint): AnsiString;
xsdFormatIntnull63 function xsdFormatInt(Value: Longint): AnsiString;
xsdFormatLongnull64 function xsdFormatLong(Value: Int64): AnsiString;
xsdFormatUnsignedBytenull65 function xsdFormatUnsignedByte(Value: Byte): AnsiString;
xsdFormatUnsignedShortnull66 function xsdFormatUnsignedShort(Value: Word): AnsiString;
xsdFormatUnsignedIntnull67 function xsdFormatUnsignedInt(Value: Longword): AnsiString;
xsdFormatUnsignedLongnull68 function xsdFormatUnsignedLong(Value: QWord): AnsiString;
xsdFormatEnumnull69 function xsdFormatEnum(enum: array of AnsiString; Value: Integer): AnsiString;
70 
71 { DateTime functions }
xsdNowUTCnull72 function xsdNowUTC: TDateTime;
xsdGetLocalTimezonenull73 function xsdGetLocalTimezone: TXsdTimezone;
xsdTimezoneUtcOffsetMinutesnull74 function xsdTimezoneUtcOffsetMinutes(const Timezone: TXsdTimezone): Longint;
xsdDateTimeToUTCnull75 function xsdDateTimeToUTC(const DateTime: TDateTime; const Current: TXsdTimezone): TDateTime;
xsdDateTimeConvertnull76 function xsdDateTimeConvert(const DateTime: TDateTime; const Current, Target: TXsdTimezone): TDateTime;
77 
78 { Parse functions }
xsdTryParseBase64null79 function xsdTryParseBase64(Chars: PChar; Len: Integer; const Value: TStream): Boolean;
xsdTryParseStringnull80 function xsdTryParseString(Chars: PChar; Len: Integer; out Value: AnsiString): Boolean;
xsdTryParseStringLowernull81 function xsdTryParseStringLower(Chars: PChar; Len: Integer; out Value: AnsiString): Boolean;
xsdTryParseBooleannull82 function xsdTryParseBoolean(Chars: PChar; Len: Integer; out Value: Boolean): Boolean;
xsdTryParseDatenull83 function xsdTryParseDate(Chars: PChar; Len: Integer; out Year, Month, Day: Longword; Timezone: PXsdTimezone = nil; BC: PBoolean = nil): Boolean;
xsdTryParseDatenull84 function xsdTryParseDate(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone = nil): Boolean;
xsdTryParseTimenull85 function xsdTryParseTime(Chars: PChar; Len: Integer; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil): Boolean;
xsdTryParseTimenull86 function xsdTryParseTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone = nil): Boolean;
xsdTryParseDateTimenull87 function xsdTryParseDateTime(Chars: PChar; Len: Integer; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil; BC: PBoolean = nil): Boolean;
xsdTryParseDateTimenull88 function xsdTryParseDateTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone = nil): Boolean;
xsdTryParseDecimalnull89 function xsdTryParseDecimal(Chars: PChar; Len: Integer; out Value: Extended): Boolean;
xsdTryParseDoublenull90 function xsdTryParseDouble(Chars: PChar; Len: Integer; out Value: Double): Boolean;
xsdTryParseFloatnull91 function xsdTryParseFloat(Chars: PChar; Len: Integer; out Value: Single): Boolean;
xsdTryParseIntegernull92 function xsdTryParseInteger(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
xsdTryParseNonNegativeIntegernull93 function xsdTryParseNonNegativeInteger(Chars: PChar; Len: Integer; out Value: QWord): Boolean;
xsdTryParseNonPositiveIntegernull94 function xsdTryParseNonPositiveInteger(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
xsdTryParseNegativeIntegernull95 function xsdTryParseNegativeInteger(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
xsdTryParsePositiveIntegernull96 function xsdTryParsePositiveInteger(Chars: PChar; Len: Integer; out Value: QWord): Boolean;
xsdTryParseBytenull97 function xsdTryParseByte(Chars: PChar; Len: Integer; out Value: Shortint): Boolean;
xsdTryParseShortnull98 function xsdTryParseShort(Chars: PChar; Len: Integer; out Value: Smallint): Boolean;
xsdTryParseIntnull99 function xsdTryParseInt(Chars: PChar; Len: Integer; out Value: Longint): Boolean;
xsdTryParseLongnull100 function xsdTryParseLong(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
xsdTryParseUnsignedBytenull101 function xsdTryParseUnsignedByte(Chars: PChar; Len: Integer; out Value: Byte): Boolean;
xsdTryParseUnsignedShortnull102 function xsdTryParseUnsignedShort(Chars: PChar; Len: Integer; out Value: Word): Boolean;
xsdTryParseUnsignedIntnull103 function xsdTryParseUnsignedInt(Chars: PChar; Len: Integer; out Value: Longword): Boolean;
xsdTryParseUnsignedLongnull104 function xsdTryParseUnsignedLong(Chars: PChar; Len: Integer; out Value: QWord): Boolean;
xsdTryParseEnumnull105 function xsdTryParseEnum(Chars: PChar; Len: Integer; enum: array of AnsiString; out Value: Integer): Boolean;
106 
xsdParseStringDefnull107 function xsdParseStringDef(Chars: PChar; Len: Integer; Default: AnsiString): AnsiString;
xsdParseStringLowerDefnull108 function xsdParseStringLowerDef(Chars: PChar; Len: Integer; Default: AnsiString): AnsiString;
xsdParseBooleanDefnull109 function xsdParseBooleanDef(Chars: PChar; Len: Integer; Default: Boolean): Boolean;
xsdParseDateDefnull110 function xsdParseDateDef(Chars: PChar; Len: Integer; Default: TDateTime; Timezone: PXsdTimezone = nil): TDateTime;
xsdParseTimeDefnull111 function xsdParseTimeDef(Chars: PChar; Len: Integer; Default: TDateTime; Timezone: PXsdTimezone = nil): TDateTime;
xsdParseDateTimeDefnull112 function xsdParseDateTimeDef(Chars: PChar; Len: Integer; Default: TDateTime; Timezone: PXsdTimezone = nil): TDateTime;
xsdParseDecimalDefnull113 function xsdParseDecimalDef(Chars: PChar; Len: Integer; Default: Extended): Extended;
xsdParseDoubleDefnull114 function xsdParseDoubleDef(Chars: PChar; Len: Integer; Default: Double): Double;
xsdParseFloatDefnull115 function xsdParseFloatDef(Chars: PChar; Len: Integer; Default: Single): Single;
xsdParseIntegerDefnull116 function xsdParseIntegerDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
xsdParseNonNegativeIntegerDefnull117 function xsdParseNonNegativeIntegerDef(Chars: PChar; Len: Integer; Default: QWord): QWord;
xsdParseNonPositiveIntegerDefnull118 function xsdParseNonPositiveIntegerDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
xsdParseNegativeIntegerDefnull119 function xsdParseNegativeIntegerDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
xsdParsePositiveIntegerDefnull120 function xsdParsePositiveIntegerDef(Chars: PChar; Len: Integer; Default: QWord): QWord;
xsdParseByteDefnull121 function xsdParseByteDef(Chars: PChar; Len: Integer; Default: Shortint): Shortint;
xsdParseShortDefnull122 function xsdParseShortDef(Chars: PChar; Len: Integer; Default: Smallint): Smallint;
xsdParseIntDefnull123 function xsdParseIntDef(Chars: PChar; Len: Integer; Default: Longint): Longint;
xsdParseLongDefnull124 function xsdParseLongDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
xsdParseUnsignedByteDefnull125 function xsdParseUnsignedByteDef(Chars: PChar; Len: Integer; Default: Byte): Byte;
xsdParseUnsignedShortDefnull126 function xsdParseUnsignedShortDef(Chars: PChar; Len: Integer; Default: Word): Word;
xsdParseUnsignedIntDefnull127 function xsdParseUnsignedIntDef(Chars: PChar; Len: Integer; Default: Longword): Longword;
xsdParseUnsignedLongDefnull128 function xsdParseUnsignedLongDef(Chars: PChar; Len: Integer; Default: QWord): QWord;
xsdParseEnumDefnull129 function xsdParseEnumDef(Chars: PChar; Len: Integer; enum: array of AnsiString; Default: Integer): Integer;
130 
131 procedure xsdParseBase64(Chars: PChar; Len: Integer; const Value: TStream);
132 procedure xsdParseString(Chars: PChar; Len: Integer; out Value: AnsiString);
133 procedure xsdParseStringLower(Chars: PChar; Len: Integer; out Value: AnsiString);
134 procedure xsdParseBoolean(Chars: PChar; Len: Integer; out Value: Boolean);
135 procedure xsdParseDate(Chars: PChar; Len: Integer; out Year, Month, Day: Longword; Timezone: PXsdTimezone = nil; BC: PBoolean = nil);
136 procedure xsdParseDate(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone = nil);
137 procedure xsdParseTime(Chars: PChar; Len: Integer; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil);
138 procedure xsdParseTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone = nil);
139 procedure xsdParseDateTime(Chars: PChar; Len: Integer; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil; BC: PBoolean = nil);
140 procedure xsdParseDateTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone = nil);
141 procedure xsdParseDecimal(Chars: PChar; Len: Integer; out Value: Extended);
142 procedure xsdParseDouble(Chars: PChar; Len: Integer; out Value: Double);
143 procedure xsdParseFloat(Chars: PChar; Len: Integer; out Value: Single);
144 procedure xsdParseInteger(Chars: PChar; Len: Integer; out Value: Int64);
145 procedure xsdParseNonNegativeInteger(Chars: PChar; Len: Integer; out Value: QWord);
146 procedure xsdParseNonPositiveInteger(Chars: PChar; Len: Integer; out Value: Int64);
147 procedure xsdParseNegativeInteger(Chars: PChar; Len: Integer; out Value: Int64);
148 procedure xsdParsePositiveInteger(Chars: PChar; Len: Integer; out Value: QWord);
149 procedure xsdParseByte(Chars: PChar; Len: Integer; out Value: Shortint);
150 procedure xsdParseShort(Chars: PChar; Len: Integer; out Value: Smallint);
151 procedure xsdParseInt(Chars: PChar; Len: Integer; out Value: Longint);
152 procedure xsdParseLong(Chars: PChar; Len: Integer; out Value: Int64);
153 procedure xsdParseUnsignedByte(Chars: PChar; Len: Integer; out Value: Byte);
154 procedure xsdParseUnsignedShort(Chars: PChar; Len: Integer; out Value: Word);
155 procedure xsdParseUnsignedInt(Chars: PChar; Len: Integer; out Value: Longword);
156 procedure xsdParseUnsignedLong(Chars: PChar; Len: Integer; out Value: QWord);
157 procedure xsdParseEnum(Chars: PChar; Len: Integer; enum: array of AnsiString; out Value: Integer);
158 
xsdParseStringnull159 function xsdParseString(Chars: PChar; Len: Integer): AnsiString;
xsdParseStringLowernull160 function xsdParseStringLower(Chars: PChar; Len: Integer): AnsiString;
xsdParseBooleannull161 function xsdParseBoolean(Chars: PChar; Len: Integer): Boolean;
xsdParseDatenull162 function xsdParseDate(Chars: PChar; Len: Integer; Timezone: PXsdTimezone = nil): TDateTime;
xsdParseTimenull163 function xsdParseTime(Chars: PChar; Len: Integer; Timezone: PXsdTimezone = nil): TDateTime;
xsdParseDateTimenull164 function xsdParseDateTime(Chars: PChar; Len: Integer; Timezone: PXsdTimezone = nil): TDateTime;
xsdParseDecimalnull165 function xsdParseDecimal(Chars: PChar; Len: Integer): Extended;
xsdParseDoublenull166 function xsdParseDouble(Chars: PChar; Len: Integer): Double;
xsdParseFloatnull167 function xsdParseFloat(Chars: PChar; Len: Integer): Single;
xsdParseIntegernull168 function xsdParseInteger(Chars: PChar; Len: Integer): Int64;
xsdParseNonNegativeIntegernull169 function xsdParseNonNegativeInteger(Chars: PChar; Len: Integer): QWord;
xsdParseNonPositiveIntegernull170 function xsdParseNonPositiveInteger(Chars: PChar; Len: Integer): Int64;
xsdParseNegativeIntegernull171 function xsdParseNegativeInteger(Chars: PChar; Len: Integer): Int64;
xsdParsePositiveIntegernull172 function xsdParsePositiveInteger(Chars: PChar; Len: Integer): QWord;
xsdParseBytenull173 function xsdParseByte(Chars: PChar; Len: Integer): Shortint;
xsdParseShortnull174 function xsdParseShort(Chars: PChar; Len: Integer): Smallint;
xsdParseIntnull175 function xsdParseInt(Chars: PChar; Len: Integer): Longint;
xsdParseLongnull176 function xsdParseLong(Chars: PChar; Len: Integer): Int64;
xsdParseUnsignedBytenull177 function xsdParseUnsignedByte(Chars: PChar; Len: Integer): Byte;
xsdParseUnsignedShortnull178 function xsdParseUnsignedShort(Chars: PChar; Len: Integer): Word;
xsdParseUnsignedIntnull179 function xsdParseUnsignedInt(Chars: PChar; Len: Integer): Longword;
xsdParseUnsignedLongnull180 function xsdParseUnsignedLong(Chars: PChar; Len: Integer): QWord;
xsdParseEnumnull181 function xsdParseEnum(Chars: PChar; Len: Integer; enum: array of AnsiString): Integer;
182 {
183 function xsdTryParseBase64(const S: AnsiString; const Value: TStream): Boolean;
184 function xsdTryParseString(const S: AnsiString; out Value: AnsiString): Boolean;
185 function xsdTryParseStringLower(const S: AnsiString; out Value: AnsiString): Boolean;
186 function xsdTryParseBoolean(const S: AnsiString; out Value: Boolean): Boolean;
187 function xsdTryParseDate(const S: AnsiString; out Year, Month, Day: Longword; Timezone: PXsdTimezone = nil; BC: PBoolean = nil): Boolean;
188 function xsdTryParseDate(const S: AnsiString; out Value: TDateTime; Timezone: PXsdTimezone = nil): Boolean;
189 function xsdTryParseTime(const S: AnsiString; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil): Boolean;
190 function xsdTryParseTime(const S: AnsiString; out Value: TDateTime; Timezone: PXsdTimezone = nil): Boolean;
191 function xsdTryParseDateTime(const S: AnsiString; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil; BC: PBoolean = nil): Boolean;
192 function xsdTryParseDateTime(const S: AnsiString; out Value: TDateTime; Timezone: PXsdTimezone = nil): Boolean;
193 function xsdTryParseDecimal(const S: AnsiString; out Value: Extended): Boolean;
194 function xsdTryParseDouble(const S: AnsiString; out Value: Double): Boolean;
195 function xsdTryParseFloat(const S: AnsiString; out Value: Single): Boolean;
196 function xsdTryParseInteger(const S: AnsiString; out Value: Int64): Boolean;
197 function xsdTryParseNonNegativeInteger(const S: AnsiString; out Value: QWord): Boolean;
198 function xsdTryParseNonPositiveInteger(const S: AnsiString; out Value: Int64): Boolean;
199 function xsdTryParseNegativeInteger(const S: AnsiString; out Value: Int64): Boolean;
200 function xsdTryParsePositiveInteger(const S: AnsiString; out Value: QWord): Boolean;
201 function xsdTryParseByte(const S: AnsiString; out Value: Shortint): Boolean;
202 function xsdTryParseShort(const S: AnsiString; out Value: Smallint): Boolean;
203 function xsdTryParseInt(const S: AnsiString; out Value: Longint): Boolean;
204 function xsdTryParseLong(const S: AnsiString; out Value: Int64): Boolean;
205 function xsdTryParseUnsignedByte(const S: AnsiString; out Value: Byte): Boolean;
206 function xsdTryParseUnsignedShort(const S: AnsiString; out Value: Word): Boolean;
207 function xsdTryParseUnsignedInt(const S: AnsiString; out Value: Longword): Boolean;
208 function xsdTryParseUnsignedLong(const S: AnsiString; out Value: QWord): Boolean;
209 function xsdTryParseEnum(const S: AnsiString; enum: array of AnsiString; out Value: Integer): Boolean;
210 
211 function xsdParseStringDef(const S: AnsiString; Default: AnsiString): AnsiString;
212 function xsdParseStringLowerDef(const S: AnsiString; Default: AnsiString): AnsiString;
213 function xsdParseBooleanDef(const S: AnsiString; Default: Boolean): Boolean;
214 function xsdParseDateDef(const S: AnsiString; Default: TDateTime; Timezone: PXsdTimezone = nil): TDateTime;
215 function xsdParseTimeDef(const S: AnsiString; Default: TDateTime; Timezone: PXsdTimezone = nil): TDateTime;
216 function xsdParseDateTimeDef(const S: AnsiString; Default: TDateTime; Timezone: PXsdTimezone = nil): TDateTime;
217 function xsdParseDecimalDef(const S: AnsiString; Default: Extended): Extended;
218 function xsdParseDoubleDef(const S: AnsiString; Default: Double): Double;
219 function xsdParseFloatDef(const S: AnsiString; Default: Single): Single;
220 function xsdParseIntegerDef(const S: AnsiString; Default: Int64): Int64;
221 function xsdParseNonNegativeIntegerDef(const S: AnsiString; Default: QWord): QWord;
222 function xsdParseNonPositiveIntegerDef(const S: AnsiString; Default: Int64): Int64;
223 function xsdParseNegativeIntegerDef(const S: AnsiString; Default: Int64): Int64;
224 function xsdParsePositiveIntegerDef(const S: AnsiString; Default: QWord): QWord;
225 function xsdParseByteDef(const S: AnsiString; Default: Shortint): Shortint;
226 function xsdParseShortDef(const S: AnsiString; Default: Smallint): Smallint;
227 function xsdParseIntDef(const S: AnsiString; Default: Longint): Longint;
228 function xsdParseLongDef(const S: AnsiString; Default: Int64): Int64;
229 function xsdParseUnsignedByteDef(const S: AnsiString; Default: Byte): Byte;
230 function xsdParseUnsignedShortDef(const S: AnsiString; Default: Word): Word;
231 function xsdParseUnsignedIntDef(const S: AnsiString; Default: Longword): Longword;
232 function xsdParseUnsignedLongDef(const S: AnsiString; Default: QWord): QWord;
233 function xsdParseEnumDef(const S: AnsiString; enum: array of AnsiString; Default: Integer): Integer;
234 }
235 procedure xsdParseBase64(const S: AnsiString; const Value: TStream);
236 procedure xsdParseString(const S: AnsiString; out Value: AnsiString);
237 procedure xsdParseStringLower(const S: AnsiString; out Value: AnsiString);
238 procedure xsdParseBoolean(const S: AnsiString; out Value: Boolean);
239 procedure xsdParseDate(const S: AnsiString; out Year, Month, Day: Longword; Timezone: PXsdTimezone = nil; BC: PBoolean = nil);
240 procedure xsdParseDate(const S: AnsiString; out Value: TDateTime; Timezone: PXsdTimezone = nil);
241 procedure xsdParseTime(const S: AnsiString; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil);
242 procedure xsdParseTime(const S: AnsiString; out Value: TDateTime; Timezone: PXsdTimezone = nil);
243 procedure xsdParseDateTime(const S: AnsiString; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone = nil; BC: PBoolean = nil);
244 procedure xsdParseDateTime(const S: AnsiString; out Value: TDateTime; Timezone: PXsdTimezone = nil);
245 procedure xsdParseDecimal(const S: AnsiString; out Value: Extended);
246 procedure xsdParseDouble(const S: AnsiString; out Value: Double);
247 procedure xsdParseFloat(const S: AnsiString; out Value: Single);
248 procedure xsdParseInteger(const S: AnsiString; out Value: Int64);
249 procedure xsdParseNonNegativeInteger(const S: AnsiString; out Value: QWord);
250 procedure xsdParseNonPositiveInteger(const S: AnsiString; out Value: Int64);
251 procedure xsdParseNegativeInteger(const S: AnsiString; out Value: Int64);
252 procedure xsdParsePositiveInteger(const S: AnsiString; out Value: QWord);
253 procedure xsdParseByte(const S: AnsiString; out Value: Shortint);
254 procedure xsdParseShort(const S: AnsiString; out Value: Smallint);
255 procedure xsdParseInt(const S: AnsiString; out Value: Longint);
256 procedure xsdParseLong(const S: AnsiString; out Value: Int64);
257 procedure xsdParseUnsignedByte(const S: AnsiString; out Value: Byte);
258 procedure xsdParseUnsignedShort(const S: AnsiString; out Value: Word);
259 procedure xsdParseUnsignedInt(const S: AnsiString; out Value: Longword);
260 procedure xsdParseUnsignedLong(const S: AnsiString; out Value: QWord);
261 procedure xsdParseEnum(const S: AnsiString; enum: array of AnsiString; out Value: Integer);
262 
xsdParseStringnull263 function xsdParseString(const S: AnsiString): AnsiString;
xsdParseStringLowernull264 function xsdParseStringLower(const S: AnsiString): AnsiString;
xsdParseBooleannull265 function xsdParseBoolean(const S: AnsiString): Boolean;
xsdParseDatenull266 function xsdParseDate(const S: AnsiString; Timezone: PXsdTimezone = nil): TDateTime;
xsdParseTimenull267 function xsdParseTime(const S: AnsiString; Timezone: PXsdTimezone = nil): TDateTime;
xsdParseDateTimenull268 function xsdParseDateTime(const S: AnsiString; Timezone: PXsdTimezone = nil): TDateTime;
xsdParseDecimalnull269 function xsdParseDecimal(const S: AnsiString): Extended;
xsdParseDoublenull270 function xsdParseDouble(const S: AnsiString): Double;
xsdParseFloatnull271 function xsdParseFloat(const S: AnsiString): Single;
xsdParseIntegernull272 function xsdParseInteger(const S: AnsiString): Int64;
xsdParseNonNegativeIntegernull273 function xsdParseNonNegativeInteger(const S: AnsiString): QWord;
xsdParseNonPositiveIntegernull274 function xsdParseNonPositiveInteger(const S: AnsiString): Int64;
xsdParseNegativeIntegernull275 function xsdParseNegativeInteger(const S: AnsiString): Int64;
xsdParsePositiveIntegernull276 function xsdParsePositiveInteger(const S: AnsiString): QWord;
xsdParseBytenull277 function xsdParseByte(const S: AnsiString): Shortint;
xsdParseShortnull278 function xsdParseShort(const S: AnsiString): Smallint;
xsdParseIntnull279 function xsdParseInt(const S: AnsiString): Longint;
xsdParseLongnull280 function xsdParseLong(const S: AnsiString): Int64;
xsdParseUnsignedBytenull281 function xsdParseUnsignedByte(const S: AnsiString): Byte;
xsdParseUnsignedShortnull282 function xsdParseUnsignedShort(const S: AnsiString): Word;
xsdParseUnsignedIntnull283 function xsdParseUnsignedInt(const S: AnsiString): Longword;
xsdParseUnsignedLongnull284 function xsdParseUnsignedLong(const S: AnsiString): QWord;
xsdParseEnumnull285 function xsdParseEnum(const S: AnsiString; enum: array of AnsiString): Integer;
286 
287 
288 { INTERNAL HELPERS!!! }
289 const
290   XSD_IGNORE_LAST = Pointer(-1); // maybe used as L parameter if the string is zero terminated
291 
__parseNonNegativeIntegernull292 function __parseNonNegativeInteger(var P: PChar; const L: PChar; out Value: QWord): Boolean;
__parseIntegernull293 function __parseInteger(var P: PChar; const L: PChar; out Value: Int64): Boolean;
__parseFloatnull294 function __parseFloat(var P: PChar; const L: PChar; out Value: Extended): Boolean;
__parseTimezonenull295 function __parseTimezone(var P: PChar; const L: PChar; out T: TXsdTimezone): Boolean;
__parseDatenull296 function __parseDate(var P: PChar; const L: PChar; out Year, Month, Day: Longword; BC: PBoolean): Boolean;
__parseTimenull297 function __parseTime(var P: PChar; const L: PChar; const AllowMoreThan24h: Boolean;
298   out Hour, Minute, Second, Milliseconds: Longword): Boolean;
__strpasnull299 function __strpas(Chars: PChar; Len: Integer): AnsiString;
300 
301 implementation
302 
xsdFormatBase64null303 function xsdFormatBase64(Value: TStream): AnsiString;
304 const
305   Base64: array[0..63] of char = (
306     'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
307     'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
308     'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
309     'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'
310   );
311   BufferSize = 3*512; { buffer size must be a multiple of 3 }
312 var
313   Buffer: array[0..BufferSize-1] of Byte;
314   Num, Ofs: Integer;
315   b1, b2, b3: Byte;
316 begin
317   Result := '';
318   while True do
319   begin
320     Num := Value.Read(Buffer, BufferSize);
321     if Num = 0 then
322       Exit;
323 
324     Ofs := 0;
325     while Num >= 3 do
326     begin
327       b1 := Buffer[Ofs];
328       b2 := Buffer[Ofs+1];
329       b3 := Buffer[Ofs+2];
330 
331       Result := Result +
332         Base64[b1 shr 2] +
333         Base64[((b1 and $3) shl 4) or (b2 shr 4)] +
334         Base64[((b2 and $F) shl 2) or (b3 shr 6)] +
335         Base64[b3 and $3F];
336 
337       Num := Num - 3;
338       Ofs := Ofs + 3;
339     end;
340 
341     case Num of
342       1: begin
343         b1 := Buffer[Ofs];
344 
345         Result := Result +
346           Base64[b1 shr 2] +
347           Base64[((b1 and $3) shl 4)] +
348           '==';
349 
350         Exit;
351       end;
352 
353       2: begin
354         b1 := Buffer[Ofs];
355         b2 := Buffer[Ofs+1];
356 
357         Result := Result +
358           Base64[b1 shr 2] +
359           Base64[((b1 and $3) shl 4) or (b2 shr 4)] +
360           Base64[((b2 and $F) shl 2)] +
361           '=';
362 
363         Exit;
364       end;
365     end;
366   end;
367 end;
368 
xsdFormatBooleannull369 function xsdFormatBoolean(Value: Boolean; UseWords: Boolean): AnsiString;
370 begin
371   if UseWords then
372     if Value then
373       Result := 'true'
374     else
375       Result := 'false'
376   else
377     if Value then
378       Result := '1'
379     else
380       Result := '0';
381 end;
382 
xsdFormatDatenull383 function xsdFormatDate(Year, Month, Day: Longword; BC: Boolean; Timezone: PXsdTimezone): AnsiString;
384 begin
385   Result := Format('%4.4d-%2.2u-%2.2u', [Year, Month, Day]);
386   if BC then
387     Result := '-' + Result;
388 
389   if Assigned(Timezone) then
390     case Timezone^.Kind of
391       tzUTC:
392         Result := Result + 'Z';
393       tzLOCAL:
394         begin
395           if Timezone^.Hour >= 0 then
396             Result := Result + '+'
397           else
398             Result := Result + '-';
399           Result := Result + Format('%2.2d:%2.2u', [Timezone^.Hour, Timezone^.Minute]);
400         end;
401     end;
402 end;
403 
xsdFormatDatenull404 function xsdFormatDate(Value: TDateTime; Timezone: PXsdTimezone): AnsiString;
405 var
406   Year, Month, Day: Word;
407 begin
408   DecodeDate(Value, Year, Month, Day);
409   Result := xsdFormatDate(Year, Month, Day, False, Timezone);
410 end;
411 
xsdFormatTimenull412 function xsdFormatTime(Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone): AnsiString;
413 begin
414   Result := Format('%2.2u:%2.2u:%2.2u', [Hour, Minute, Second]);
415   if Milliseconds > 0 then
416     Result := Result + '.' + IntToStr(Milliseconds);
417 
418   if Assigned(Timezone) then
419     case Timezone^.Kind of
420       tzUTC:
421         Result := Result + 'Z';
422       tzLOCAL:
423         begin
424           if Timezone^.Hour >= 0 then
425             Result := Result + '+'
426           else
427             Result := Result + '-';
428           Result := Result + Format('%2.2d:%2.2u', [Timezone^.Hour, Timezone^.Minute]);
429         end;
430     end;
431 end;
432 
xsdFormatTimenull433 function xsdFormatTime(Value: TDateTime; Timezone: PXsdTimezone): AnsiString;
434 var
435   Hour, Minute, Second, Milliseconds: Word;
436 begin
437   DecodeTime(Value, Hour, Minute, Second, Milliseconds);
438   Result := xsdFormatTime(Hour, Minute, Second, Milliseconds, Timezone);
439 end;
440 
xsdFormatDateTimenull441 function xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; BC: Boolean; Timezone: PXsdTimezone): AnsiString;
442 begin
443   Result := xsdFormatDate(Year, Month, Day, BC, nil) + 'T' + xsdFormatTime(Hour, Minute, Second, Milliseconds, Timezone);
444 end;
445 
xsdFormatDateTimenull446 function xsdFormatDateTime(Value: TDateTime; Timezone: PXsdTimezone): AnsiString;
447 var
448   Year, Month, Day, Hour, Minute, Second, Milliseconds: Word;
449 begin
450   DecodeDateTime(Value, Year, Month, Day, Hour, Minute, Second, Milliseconds);
451   Result := xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds, False, Timezone);
452 end;
453 
xsdFormatDecimalnull454 function xsdFormatDecimal(Value: Extended; Precision: Integer; Digits: Integer): AnsiString;
455 begin
456   Result := FloatToStrF(Value, ffFixed, Precision, Digits);
457 end;
458 
xsdFormatDoublenull459 function xsdFormatDouble(Value: Double): AnsiString;
460 begin
461   Result := FloatToStr(Value);
462 end;
463 
xsdFormatFloatnull464 function xsdFormatFloat(Value: Single): AnsiString;
465 begin
466   Result := FloatToStr(Value);
467 end;
468 
xsdFormatBytenull469 function xsdFormatByte(Value: Shortint): AnsiString;
470 begin
471   Result := IntToStr(Value);
472 end;
473 
xsdFormatShortnull474 function xsdFormatShort(Value: Smallint): AnsiString;
475 begin
476   Result := IntToStr(Value);
477 end;
478 
xsdFormatIntnull479 function xsdFormatInt(Value: Integer): AnsiString;
480 begin
481   Result := IntToStr(Value);
482 end;
483 
xsdFormatLongnull484 function xsdFormatLong(Value: Int64): AnsiString;
485 begin
486   Result := IntToStr(Value);
487 end;
488 
xsdFormatUnsignedBytenull489 function xsdFormatUnsignedByte(Value: Byte): AnsiString;
490 begin
491   Result := IntToStr(Value);
492 end;
493 
xsdFormatUnsignedShortnull494 function xsdFormatUnsignedShort(Value: Word): AnsiString;
495 begin
496   Result := IntToStr(Value);
497 end;
498 
xsdFormatUnsignedIntnull499 function xsdFormatUnsignedInt(Value: Longword): AnsiString;
500 begin
501   Result := IntToStr(Value);
502 end;
503 
xsdFormatUnsignedLongnull504 function xsdFormatUnsignedLong(Value: QWord): AnsiString;
505 begin
506   Result := IntToStr(Value);
507 end;
508 
xsdFormatEnumnull509 function xsdFormatEnum(enum: array of AnsiString; Value: Integer): AnsiString;
510 begin
511   Result := enum[Value];
512 end;
513 
xsdNowUTCnull514 function xsdNowUTC: TDateTime;
515 begin
516   Result := xsdDateTimeToUTC(Now, xsdGetLocalTimezone);
517 end;
518 
xsdGetLocalTimezonenull519 function xsdGetLocalTimezone: TXsdTimezone;
520 var
521   Offset: Integer;
522 {$IFDEF MSWINDOWS}
523   TZInfo: TTimeZoneInformation;
524 {$ENDIF}
525 begin
526   Result.Kind := tzLOCAL;
527 {$IFDEF UNIX}
528   Offset := Tzseconds div 60;
529 {$ENDIF}
530 {$IFDEF MSWINDOWS}
531   case GetTimeZoneInformation(TZInfo) of
532     1: Offset := -TZInfo.Bias - TZInfo.StandardBias;
533     2: Offset := -TZInfo.Bias - TZInfo.DaylightBias;
534     else Result.Kind := tzUnknown;
535   end;
536 {$ENDIF}
537   Result.Hour := Offset div 60;
538   Result.Minute := abs(Offset) mod 60;
539 end;
540 
xsdTimezoneUtcOffsetMinutesnull541 function xsdTimezoneUtcOffsetMinutes(const Timezone: TXsdTimezone): Longint;
542 begin
543   case Timezone.Kind of
544     tzUTC: Result := 0;
545     tzLOCAL : Result := 60*Timezone.Hour + Timezone.Minute;
546     else raise Exception.Create('can''t get offset of unknown timezone');
547   end;
548 end;
549 
xsdDateTimeToUTCnull550 function xsdDateTimeToUTC(const DateTime: TDateTime; const Current: TXsdTimezone): TDateTime;
551 begin
552   Result := xsdDateTimeConvert(DateTime, Current, TIMEZONE_UTC);
553 end;
554 
xsdDateTimeConvertnull555 function xsdDateTimeConvert(const DateTime: TDateTime; const Current, Target: TXsdTimezone): TDateTime;
556 begin
557   Result := IncMinute(DateTime, xsdTimezoneUtcOffsetMinutes(Target) - xsdTimezoneUtcOffsetMinutes(Current));
558 end;
559 
__parseNonNegativeIntegernull560 function __parseNonNegativeInteger(var P: PChar; const L: PChar; out Value: QWord): Boolean;
561 begin
562   { expect integer }
563   Value := 0;
564   while (P < L) and (P^ in ['0'..'9']) do
565   begin
566     Value := 10*Value + Ord(P^) - Ord('0');
567     Inc(P);
568   end;
569 
570   Result := True;
571 end;
572 
__parseIntegernull573 function __parseInteger(var P: PChar; const L: PChar; out Value: Int64): Boolean;
574 var
575   N: Boolean;
576 begin
577   { allow '-' }
578   N := (P < L) and (P^ = '-');
579   if N then
580     Inc(P);
581 
582   { expect integer }
583   Value := 0;
584   while (P < L) and (P^ in ['0'..'9']) do
585   begin
586     Value := 10*Value + Ord(P^) - Ord('0');
587     Inc(P);
588   end;
589   if N then
590     Value := -Value;
591 
592   Result := True;
593 end;
594 
__parseFloatnull595 function __parseFloat(var P: PChar; const L: PChar; out Value: Extended): Boolean;
596 var
597   N: Boolean;
598   Exp: Int64;
599   Int: QWord;
600 begin
601   { allow 'Nan' }
602   if (P+2 < L) and ((P^ = 'N') or (P^ = 'n')) then
603   begin
604     Inc(P);
605     if (P^ <> 'A') and (P^ <> 'a') then Exit(False);
606     Inc(P);
607     if (P^ <> 'N') and (P^ <> 'n') then Exit(False);
608     Inc(P);
609     Value := Nan;
610     Result := True;
611     Exit;
612   end;
613 
614   { allow '-' }
615   N := (P < L) and (P^ = '-');
616   if N then
617     Inc(P);
618 
619   { allow 'Inf' }
620   if (P+2 < L) and ((P^ = 'I') or (P^ = 'i')) then
621   begin
622     Inc(P);
623     if (P^ <> 'N') and (P^ <> 'n') then Exit(False);
624     Inc(P);
625     if (P^ <> 'F') and (P^ <> 'f') then Exit(False);
626     Inc(P);
627     if N then
628       Value := NegInfinity
629     else
630       Value := Infinity;
631     Result := True;
632     Exit;
633   end;
634 
635   { expect integer }
636   Int := 0;
637   while (P < L) and (P^ in ['0'..'9']) do
638   begin
639     Int := 10*Int + Ord(P^) - Ord('0');
640     Inc(P);
641   end;
642   Value := Int;
643 
644   { allow '.' }
645   if (P < L) and (P^ = '.') then
646   begin
647     Inc(P);
648 
649     { expect integer }
650     Exp := 1;
651     Int := 0;
652     while (P < L) and (P^ in ['0'..'9']) do
653     begin
654       Int := 10*Int + Ord(P^) - Ord('0');
655       Exp := 10*Exp;
656       Inc(P);
657     end;
658     Value := Value + Int / Exp;
659   end;
660 
661   { allow 'E' or 'e' }
662   if (P < L) and ((P^ = 'E') or (P^ = 'e')) then
663   begin
664     Inc(P);
665 
666     { expect integer }
667     if not __parseInteger(P, L, Exp) then
668       Exit(False);
669 
670     while Exp > 0 do
671     begin
672       Value := Value * 10;
673       Dec(Exp);
674     end;
675 
676     while Exp < 0 do
677     begin
678       Value := Value * 0.1;
679       Inc(Exp);
680     end;
681   end;
682 
683   if N then
684     Value := -Value;
685 
686   Result := True;
687 end;
688 
__parseTimezonenull689 function __parseTimezone(var P: PChar; const L: PChar; out T: TXsdTimezone): Boolean;
690 var
691   I: Integer;
692   N: Boolean;
693 begin
694   { allow 'Z' }
695   if (P < L) and (P^ = 'Z') then
696   begin
697     T.Kind := tzUTC;
698     T.Hour := 0;
699     T.Minute := 0;
700     Inc(P);
701   end else
702 
703     { allow '+' or '-' }
704     if (P < L) and (P^ in ['+','-']) then
705     begin
706       T.Kind := tzLOCAL;
707       N := P^ = '-';
708       Inc(P);
709 
710       { expect 00..13 }
711       T.Hour := 0; I := 2;
712       while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
713       begin
714         T.Hour := 10*T.Hour + Ord(P^) - Ord('0');
715         Dec(I); Inc(P);
716       end;
717       if T.Hour > 13 then
718         Exit(False);
719       if N then
720         T.Hour := -T.Hour;
721 
722       { expect ':' }
723       if (P >= L) or (P^ <> ':') then
724         Exit(False);
725       Inc(P);
726 
727       { expect 00..59 }
728       T.Minute := 0; I := 2;
729       while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
730       begin
731         T.Minute := 10*T.Minute + Ord(P^) - Ord('0');
732         Dec(I); Inc(P);
733       end;
734       if T.Minute > 59 then
735         Exit(False);
736     end else
737 
738       { unknown }
739       begin
740         T.Kind := tzUNKNOWN;
741         T.Hour := 0;
742         T.Minute := 0;
743       end;
744 
745   Result := True;
746 end;
747 
__parseDatenull748 function __parseDate(var P: PChar; const L: PChar; out Year, Month, Day: Longword; BC: PBoolean): Boolean;
749 var
750   I: Integer;
751 begin
752   { allow '-' }
753   if (P < L) and (P^ = '-') then
754   begin
755     if Assigned(BC) then
756       BC^ := True
757     else
758       Exit(False);
759     Inc(P);
760   end else
761     if Assigned(BC) then
762       BC^ := False;
763 
764   { expect Integer }
765   Year := 0;
766   while (P < L) and (P^ in ['0'..'9']) do
767   begin
768     Year := 10*Year + Ord(P^) - Ord('0');
769     Inc(P);
770   end;
771 
772   { expect '-' }
773   if (P >= L) or (P^ <> '-') then
774     Exit(False);
775   Inc(P);
776 
777   { expect 01..12 }
778   Month := 0; I := 2;
779   while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
780   begin
781     Month := 10*Month + Ord(P^) - Ord('0');
782     Dec(I); Inc(P);
783   end;
784   if (Month < 1) or (Month > 12) then
785     Exit(False);
786 
787   { expect '-' }
788   if (P >= L) or (P^ <> '-') then
789     Exit(False);
790   Inc(P);
791 
792   { expect 01..31 }
793   Day := 0; I := 2;
794   while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
795   begin
796     Day := 10*Day + Ord(P^) - Ord('0');
797     Dec(I); Inc(P);
798   end;
799   if (Day < 1) or (Day > 31) then
800     Exit(False);
801 
802   Result := True;
803 end;
804 
__parseTimenull805 function __parseTime(var P: PChar; const L: PChar; const AllowMoreThan24h: Boolean;
806   out Hour, Minute, Second, Milliseconds: Longword): Boolean;
807 var
808   I: Integer;
809   Ms: Longword;
810 begin
811   { expect 00..24 (except if AllowMoreThan24h) }
812   Hour := 0;
813   if AllowMoreThan24h then I := 9 { maximal 9 digits for hour } else I := 2;
814   while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
815   begin
816     Hour := 10*Hour + Ord(P^) - Ord('0');
817     Inc(P); Dec(I);
818   end;
819   if not AllowMoreThan24h and (Hour > 24) then
820     Exit(False);
821 
822   { expect ':' }
823   if (P >= L) or (P^ <> ':') then
824     Exit(False);
825   Inc(P);
826 
827   { expect 00..59 }
828   Minute := 0; I := 2;
829   while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
830   begin
831     Minute := 10*Minute + Ord(P^) - Ord('0');
832     Dec(I); Inc(P);
833   end;
834   if (Minute > 59) or (not AllowMoreThan24h and (Hour = 24) and (Minute > 0)) then
835     Exit(False);
836 
837   { expect ':' }
838   if (P >= L) or (P^ <> ':') then
839     Exit(False);
840   Inc(P);
841 
842   { expect 00..59 }
843   Second := 0; I := 2;
844   while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
845   begin
846     Second := 10*Second + Ord(P^) - Ord('0');
847     Dec(I); Inc(P);
848   end;
849   if (Second > 59) or (not AllowMoreThan24h and (Hour = 24) and (Second > 0)) then
850     Exit(False);
851 
852   { allow '.' }
853   if (P < L) and (P^ = '.') then
854   begin
855     Inc(P);
856 
857     { expect integer }
858     Ms := 0; I := 1;
859     while (P < L) and (P^ in ['0'..'9']) do
860     begin
861       Ms := 10*Ms + Ord(P^) - Ord('0');
862       I := 10*I;
863       Inc(P);
864     end;
865     Milliseconds := (1000*Ms) div I;
866     if (Milliseconds >= 999) or (not AllowMoreThan24h and (Hour = 24) and (Milliseconds > 0)) then
867       Exit(False);
868   end else
869     Milliseconds := 0;
870 
871   Result := True;
872 end;
873 
xsdTryParseBase64null874 function xsdTryParseBase64(Chars: PChar; Len: Integer; const Value: TStream): Boolean;
875 const
876   BufferSize = 3*512;
877 var
878   Buffer: array[0..BufferSize-1] of Byte;
879   Ofs: Integer;
880   P,L: PByte;
881   p1,p2,p3,p4: Shortint;
882 begin
883   if Assigned(Chars) then
884   begin
885     Ofs := 0;
886 
887     P := PByte(Chars);
888     if Len >= 0 then
889     begin
890       if Len mod 4 <> 0 then
891         Exit(False);
892 
893       L := P + Len;
894       while P < L do
895       begin
896         case Chr(P^) of
897           'A'..'Z': p1 := P^ - Ord('A');
898           'a'..'z': p1 := P^ - Ord('a') + 26;
899           '0'..'9': p1 := P^ - Ord('0') + 52;
900           '+' : p1 := 62;
901           '/' : p1 := 63;
902           else Exit(False);
903         end;
904         Inc(P);
905 
906         case Chr(P^) of
907           'A'..'Z': p2 := P^ - Ord('A');
908           'a'..'z': p2 := P^ - Ord('a') + 26;
909           '0'..'9': p2 := P^ - Ord('0') + 52;
910           '+' : p2 := 62;
911           '/' : p2 := 63;
912           else Exit(False);
913         end;
914         Inc(P);
915 
916         case Chr(P^) of
917           'A'..'Z': p3 := P^ - Ord('A');
918           'a'..'z': p3 := P^ - Ord('a') + 26;
919           '0'..'9': p3 := P^ - Ord('0') + 52;
920           '+' : p3 := 62;
921           '/' : p3 := 63;
922           '=' : p3 := -1;
923           else Exit(False);
924         end;
925         Inc(P);
926 
927         if (p3 >= 0) then
928         begin
929           case Chr(P^) of
930             'A'..'Z': p4 := P^ - Ord('A');
931             'a'..'z': p4 := P^ - Ord('a') + 26;
932             '0'..'9': p4 := P^ - Ord('0') + 52;
933             '+' : p4 := 62;
934             '/' : p4 := 63;
935             '=' : p4 := -1;
936             else Exit(False);
937           end;
938         end else begin
939           if P^ <> Ord('=') then
940             Exit(False);
941           p4 := -1;
942         end;
943         Inc(P);
944 
945         Buffer[Ofs] := (p1 shl 2) or (p2 shr 4);
946         Ofs := Ofs + 1;
947 
948         if p3 >= 0 then
949         begin
950           Buffer[Ofs] := ((p2 and $F) shl 4) or (p3 shr 2);
951           Ofs := Ofs + 1;
952 
953           if p4 >= 0 then
954           begin
955             Buffer[Ofs] := ((p3 and $3) shl 6) or p4;
956             Ofs := Ofs + 1;
957           end;
958         end;
959 
960         if Ofs >= BufferSize-2 then
961         begin
962           Value.Write(Buffer, Ofs);
963           Ofs := 0;
964         end;
965       end;
966     end else begin
967       while P^ <> 0 do
968       begin
969         case Chr(P^) of
970           'A'..'Z': p1 := P^ - Ord('A');
971           'a'..'z': p1 := P^ - Ord('a') + 26;
972           '0'..'9': p1 := P^ - Ord('0') + 52;
973           '+' : p1 := 62;
974           '/' : p1 := 63;
975           else Exit(False);
976         end;
977         Inc(P);
978 
979         case Chr(P^) of
980           'A'..'Z': p2 := P^ - Ord('A');
981           'a'..'z': p2 := P^ - Ord('a') + 26;
982           '0'..'9': p2 := P^ - Ord('0') + 52;
983           '+' : p2 := 62;
984           '/' : p2 := 63;
985           else Exit(False);
986         end;
987         Inc(P);
988 
989         case Chr(P^) of
990           'A'..'Z': p3 := P^ - Ord('A');
991           'a'..'z': p3 := P^ - Ord('a') + 26;
992           '0'..'9': p3 := P^ - Ord('0') + 52;
993           '+' : p3 := 62;
994           '/' : p3 := 63;
995           '=' : p3 := -1;
996           else Exit(False);
997         end;
998         Inc(P);
999 
1000         if (p3 >= 0) then
1001         begin
1002           case Chr(P^) of
1003             'A'..'Z': p4 := P^ - Ord('A');
1004             'a'..'z': p4 := P^ - Ord('a') + 26;
1005             '0'..'9': p4 := P^ - Ord('0') + 52;
1006             '+' : p4 := 62;
1007             '/' : p4 := 63;
1008             '=' : p4 := -1;
1009             else Exit(False);
1010           end;
1011         end else begin
1012           if P^ <> Ord('=') then
1013             Exit(False);
1014           p4 := -1;
1015         end;
1016         Inc(P);
1017 
1018         Buffer[Ofs] := (p1 shl 2) or (p2 shr 4);
1019         Ofs := Ofs + 1;
1020 
1021         if p3 >= 0 then
1022         begin
1023           Buffer[Ofs] := ((p2 and $F) shl 4) or (p3 shr 2);
1024           Ofs := Ofs + 1;
1025 
1026           if p4 >= 0 then
1027           begin
1028             Buffer[Ofs] := ((p3 and $3) shl 6) or p4;
1029             Ofs := Ofs + 1;
1030           end;
1031         end;
1032 
1033         if Ofs >= BufferSize-2 then
1034         begin
1035           Value.Write(Buffer, Ofs);
1036           Ofs := 0;
1037         end;
1038       end;
1039     end;
1040 
1041     if Ofs > 0 then // flush
1042       Value.Write(Buffer, Ofs);
1043 
1044     Result := True;
1045   end else
1046     Result := False;
1047 end;
1048 
xsdTryParseStringnull1049 function xsdTryParseString(Chars: PChar; Len: Integer; out Value: AnsiString): Boolean;
1050 const
1051   AllocChars = 256;
1052 var
1053   P,L,D: PByte;
1054 begin
1055   if Assigned(Chars) then
1056   begin
1057     P := PByte(Chars);
1058     if Len >= 0 then
1059     begin
1060       L := P + Len;
1061       SetLength(Value, Len);
1062       D := @Value[1];
1063       while P < L do
1064       begin
1065         D^ := P^;
1066         Inc(D);
1067         Inc(P);
1068       end;
1069     end else begin
1070       SetLength(Value, AllocChars);
1071       D := @Value[1];
1072       L := D + AllocChars;
1073       while P^ <> 0 do
1074       begin
1075         if D = L then
1076         begin
1077           Len := Length(Value);
1078           SetLength(Value, Len+AllocChars);
1079           D := @Value[Len+1];
1080           L := D + AllocChars;
1081         end;
1082         D^ := P^;
1083         Inc(D);
1084         Inc(P);
1085       end;
1086       SetLength(Value, P-PByte(Chars));
1087     end;
1088     Result := True;
1089   end else
1090     Result := False;
1091 end;
1092 {begin
1093   if Assigned(Chars) then
1094   begin
1095     if Len >= 0 then
1096     begin
1097       SetLength(Value, Len);
1098       Move(Chars^, Value[1], Len);
1099     end else
1100       Value := PChar(Chars);
1101     Result := True;
1102   end else
1103     Result := False;
1104 end;}
1105 
xsdTryParseStringLowernull1106 function xsdTryParseStringLower(Chars: PChar; Len: Integer; out Value: AnsiString): Boolean;
1107 const
1108   AllocChars = 256;
1109 var
1110   P,L,D: PByte;
1111   C: Byte;
1112 begin
1113   if Assigned(Chars) then
1114   begin
1115     P := PByte(Chars);
1116     if Len >= 0 then
1117     begin
1118       L := P + Len;
1119       SetLength(Value, Len);
1120       D := @Value[1];
1121       while P < L do
1122       begin
1123         C := P^;
1124         if (C>=65) and (C<=90) then Inc(C, 32);
1125         D^ := C;
1126         Inc(D);
1127         Inc(P);
1128       end;
1129     end else begin
1130       SetLength(Value, AllocChars);
1131       D := @Value[1];
1132       L := D + AllocChars;
1133       while P^ <> 0 do
1134       begin
1135         C := P^;
1136         if (C>=65) and (C<=90) then Inc(C, 32);
1137         if D = L then
1138         begin
1139           Len := Length(Value);
1140           SetLength(Value, Len+AllocChars);
1141           D := @Value[Len+1];
1142           L := D + AllocChars;
1143         end;
1144         D^ := C;
1145         Inc(D);
1146         Inc(P);
1147       end;
1148       SetLength(Value, P-PByte(Chars));
1149     end;
1150     Result := True;
1151   end else
1152     Result := False;
1153 end;
1154 
__strpasnull1155 function __strpas(Chars: PChar; Len: Integer): AnsiString;
1156 begin
1157   if not xsdTryParseString(Chars, Len, Result) then
1158     Result := '';
1159 end;
1160 
xsdTryParseBooleannull1161 function xsdTryParseBoolean(Chars: PChar; Len: Integer; out Value: Boolean): Boolean;
1162 var
1163   P: PChar;
1164   Num: QWord;
1165 begin
1166   if not Assigned(Chars) then
1167     Exit(False);
1168 
1169   if Len < 0 then
1170   begin
1171     P := PChar(Chars);
1172     Len := 0;
1173     while (Len < 7) and (P^ <> #0) do
1174     begin
1175       Inc(Len);
1176       Inc(P);
1177     end;
1178   end;
1179 
1180   case Len of
1181     1: Num := PByte(Chars)^;
1182     4: Num := PLongword(Chars)^;
1183     5: Num := PLongword(Chars)^ or (QWord(Chars[4]) shl 32);
1184     else Exit(False);
1185   end;
1186 
1187   case Num of
1188     $30,
1189     $65736C6166,$65736C6146,$65736C4166,$65736C4146,$65734C6166,$65734C6146,$65734C4166,$65734C4146,
1190     $65536C6166,$65536C6146,$65536C4166,$65536C4146,$65534C6166,$65534C6146,$65534C4166,$65534C4146,
1191     $45736C6166,$45736C6146,$45736C4166,$45736C4146,$45734C6166,$45734C6146,$45734C4166,$45734C4146,
1192     $45536C6166,$45536C6146,$45536C4166,$45536C4146,$45534C6166,$45534C6146,$45534C4166,$45534C4146:
1193       Value := False;
1194     $31,
1195     $65757274,$65757254,$65755274,$65755254,$65557274,$65557254,$65555274,$65555254,
1196     $45757274,$45757254,$45755274,$45755254,$45557274,$45557254,$45555274,$45555254:
1197       Value := True;
1198     else Exit(False);
1199   end;
1200 
1201   Result := True;
1202 end;
1203 
xsdTryParseDatenull1204 function xsdTryParseDate(Chars: PChar; Len: Integer; out Year, Month, Day: Longword; Timezone: PXsdTimezone; BC: PBoolean): Boolean;
1205 var
1206   P: PChar;
1207   L: PChar;
1208   T: TXsdTimezone;
1209 begin
1210   P := PChar(Chars);
1211   if Len >= 0 then
1212   begin
1213     L := P + Len;
1214     Result := Assigned(P) and
1215       __parseDate(P, L, Year, Month, Day, BC) and
1216       __parseTimezone(P, L, T) and (P = L)
1217   end else
1218     Result := Assigned(P) and
1219       __parseDate(P, XSD_IGNORE_LAST, Year, Month, Day, BC) and
1220       __parseTimezone(P, XSD_IGNORE_LAST, T) and (P^ = #0);
1221 
1222   { assign Timezone if requested }
1223   if Result and Assigned(Timezone) then
1224     Timezone^ := T;
1225 end;
1226 
xsdTryParseDatenull1227 function xsdTryParseDate(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone): Boolean;
1228 var
1229   Year, Month, Day: Longword;
1230 begin
1231   if xsdTryParseDate(Chars, Len, Year, Month, Day, Timezone, nil) then
1232     Result := TryEncodeDate(Year, Month, Day, Value)
1233   else
1234     Result := False;
1235 end;
1236 
xsdTryParseTimenull1237 function xsdTryParseTime(Chars: PChar; Len: Integer; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone): Boolean;
1238 var
1239   P: PChar;
1240   L: PChar;
1241   T: TXsdTimezone;
1242 begin
1243   P := PChar(Chars);
1244   if Len >= 0 then
1245   begin
1246     L := P + Len;
1247     Result := Assigned(P) and
1248       __parseTime(P, L, False, Hour, Minute, Second, Milliseconds) and
1249       __parseTimezone(P, L, T) and (P = L)
1250   end else
1251     Result := Assigned(P) and
1252       __parseTime(P, XSD_IGNORE_LAST, False, Hour, Minute, Second, Milliseconds) and
1253       __parseTimezone(P, XSD_IGNORE_LAST, T) and (P^ = #0);
1254 
1255   { assign Timezone if requested }
1256   if Result and Assigned(Timezone) then
1257     Timezone^ := T;
1258 end;
1259 
xsdTryParseTimenull1260 function xsdTryParseTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone): Boolean;
1261 var
1262   Hour, Minute, Second, Milliseconds: Longword;
1263 begin
1264   if xsdTryParseTime(Chars, Len, Hour, Minute, Second, Milliseconds, Timezone) then
1265     Result := TryEncodeTime(Hour, Minute, Second, Milliseconds, Value)
1266   else
1267     Result := False;
1268 end;
1269 
xsdTryParseDateTimenull1270 function xsdTryParseDateTime(Chars: PChar; Len: Integer; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone; BC: PBoolean): Boolean;
1271 
__parseTnull1272     function __parseT(var P: PChar; const L: PChar): Boolean;
1273     begin
1274       Result := (P < L) and (P^ = 'T');
1275       if Result then Inc(P);
1276     end;
1277 
1278 var
1279   P: PChar;
1280   L: PChar;
1281   T: TXsdTimezone;
1282 begin
1283   P := PChar(Chars);
1284   if Len >= 0 then
1285   begin
1286     L := P + Len;
1287     Result := Assigned(P) and
1288       __parseDate(P, L, Year, Month, Day, BC) and
1289       __parseT(P, L) and
1290       __parseTime(P, L, False, Hour, Minute, Second, Milliseconds) and
1291       __parseTimezone(P, L, T) and (P = L)
1292   end else
1293     Result := Assigned(P) and
1294       __parseDate(P, XSD_IGNORE_LAST, Year, Month, Day, BC) and
1295       __parseT(P, XSD_IGNORE_LAST) and
1296       __parseTime(P, XSD_IGNORE_LAST, False, Hour, Minute, Second, Milliseconds) and
1297       __parseTimezone(P, XSD_IGNORE_LAST, T) and (P^ = #0);
1298 
1299   { assign Timezone if requested }
1300   if Result and Assigned(Timezone) then
1301     Timezone^ := T;
1302 end;
1303 
xsdTryParseDateTimenull1304 function xsdTryParseDateTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone): Boolean;
1305 var
1306   Year, Month, Day: Longword;
1307   Hour, Minute, Second, Milliseconds: Longword;
1308 begin
1309   if xsdTryParseDateTime(Chars, Len, Year, Month, Day, Hour, Minute, Second, Milliseconds, Timezone) then
1310     Result := TryEncodeDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds, Value)
1311   else
1312     Result := False;
1313 end;
1314 
xsdTryParseDecimalnull1315 function xsdTryParseDecimal(Chars: PChar; Len: Integer; out Value: Extended): Boolean;
1316 var
1317   P: PChar;
1318   L: PChar;
1319 begin
1320   P := PChar(Chars);
1321   if Len >= 0 then
1322   begin
1323     L := P + Len;
1324     Result := Assigned(P) and __parseFloat(P, L, Value) and (P = L)
1325   end else
1326     Result := Assigned(P) and __parseFloat(P, XSD_IGNORE_LAST, Value) and (P^ = #0);
1327 end;
1328 
xsdTryParseDoublenull1329 function xsdTryParseDouble(Chars: PChar; Len: Integer; out Value: Double): Boolean;
1330 var
1331   P: PChar;
1332   L: PChar;
1333   Tmp: Extended;
1334 begin
1335   P := PChar(Chars);
1336   if Len >= 0 then
1337   begin
1338     L := P + Len;
1339     Result := Assigned(P) and __parseFloat(P, L, Tmp) and (P = L)
1340   end else
1341     Result := Assigned(P) and __parseFloat(P, XSD_IGNORE_LAST, Tmp) and (P^ = #0);
1342   Value := Tmp;
1343 end;
1344 
xsdTryParseFloatnull1345 function xsdTryParseFloat(Chars: PChar; Len: Integer; out Value: Single): Boolean;
1346 var
1347   P: PChar;
1348   L: PChar;
1349   Tmp: Extended;
1350 begin
1351   P := PChar(Chars);
1352   if Len >= 0 then
1353   begin
1354     L := P + Len;
1355     Result := Assigned(P) and __parseFloat(P, L, Tmp) and (P = L)
1356   end else
1357     Result := Assigned(P) and __parseFloat(P, XSD_IGNORE_LAST, Tmp) and (P^ = #0);
1358   Value := Tmp;
1359 end;
1360 
xsdTryParseIntegernull1361 function xsdTryParseInteger(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
1362 var
1363   P: PChar;
1364   L: PChar;
1365 begin
1366   P := PChar(Chars);
1367   if Len >= 0 then
1368   begin
1369     L := P + Len;
1370     Result := Assigned(P) and __parseInteger(P, L, Value) and (P = L)
1371   end else
1372     Result := Assigned(P) and __parseInteger(P, XSD_IGNORE_LAST, Value) and (P^ = #0);
1373 end;
1374 
xsdTryParseNonNegativeIntegernull1375 function xsdTryParseNonNegativeInteger(Chars: PChar; Len: Integer; out Value: QWord): Boolean;
1376 var
1377   P: PChar;
1378   L: PChar;
1379 begin
1380   P := PChar(Chars);
1381   if Len >= 0 then
1382   begin
1383     L := P + Len;
1384     Result := Assigned(P) and __parseNonNegativeInteger(P, L, Value) and (P = L)
1385   end else
1386     Result := Assigned(P) and __parseNonNegativeInteger(P, XSD_IGNORE_LAST, Value) and (P^ = #0);
1387 end;
1388 
xsdTryParseNonPositiveIntegernull1389 function xsdTryParseNonPositiveInteger(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
1390 begin
1391   Result := xsdTryParseInteger(Chars, Len, Value) and (Value <= 0);
1392 end;
1393 
xsdTryParseNegativeIntegernull1394 function xsdTryParseNegativeInteger(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
1395 begin
1396   Result := xsdTryParseInteger(Chars, Len, Value) and (Value <= -1);
1397 end;
1398 
xsdTryParsePositiveIntegernull1399 function xsdTryParsePositiveInteger(Chars: PChar; Len: Integer; out Value: QWord): Boolean;
1400 begin
1401   Result := xsdTryParseNonNegativeInteger(Chars, Len, Value) and (Value >= 1);
1402 end;
1403 
xsdTryParseBytenull1404 function xsdTryParseByte(Chars: PChar; Len: Integer; out Value: Shortint): Boolean;
1405 var
1406   Tmp: Int64;
1407 begin
1408   Result := xsdTryParseInteger(Chars, Len, Tmp) and (Tmp <= 128) and (Tmp >= -127);
1409   Value := Tmp;
1410 end;
1411 
xsdTryParseShortnull1412 function xsdTryParseShort(Chars: PChar; Len: Integer; out Value: Smallint): Boolean;
1413 var
1414   Tmp: Int64;
1415 begin
1416   Result := xsdTryParseInteger(Chars, Len, Tmp) and (Tmp <= 32767) and (Tmp >= -32768);
1417   Value := Tmp;
1418 end;
1419 
xsdTryParseIntnull1420 function xsdTryParseInt(Chars: PChar; Len: Integer; out Value: Longint): Boolean;
1421 var
1422   Tmp: Int64;
1423 begin
1424   Result := xsdTryParseInteger(Chars, Len, Tmp) and (Tmp <= 2147483647) and (Tmp >= -2147483648);
1425   Value := Tmp;
1426 end;
1427 
xsdTryParseLongnull1428 function xsdTryParseLong(Chars: PChar; Len: Integer; out Value: Int64): Boolean;
1429 begin
1430   Result := xsdTryParseInteger(Chars, Len, Value);
1431 end;
1432 
xsdTryParseUnsignedBytenull1433 function xsdTryParseUnsignedByte(Chars: PChar; Len: Integer; out Value: Byte): Boolean;
1434 var
1435   Tmp: QWord;
1436 begin
1437   Result := xsdTryParseNonNegativeInteger(Chars, Len, Tmp) and (Tmp <= 255);
1438   Value := Tmp;
1439 end;
1440 
xsdTryParseUnsignedShortnull1441 function xsdTryParseUnsignedShort(Chars: PChar; Len: Integer; out Value: Word): Boolean;
1442 var
1443   Tmp: QWord;
1444 begin
1445   Result := xsdTryParseNonNegativeInteger(Chars, Len, Tmp) and (Tmp <= 65535);
1446   Value := Tmp;
1447 end;
1448 
xsdTryParseUnsignedIntnull1449 function xsdTryParseUnsignedInt(Chars: PChar; Len: Integer; out Value: Longword): Boolean;
1450 var
1451   Tmp: QWord;
1452 begin
1453   Result := xsdTryParseNonNegativeInteger(Chars, Len, Tmp) and (Tmp <= 4294967295);
1454   Value := Tmp;
1455 end;
1456 
xsdTryParseUnsignedLongnull1457 function xsdTryParseUnsignedLong(Chars: PChar; Len: Integer; out Value: QWord): Boolean;
1458 begin
1459   Result := xsdTryParseNonNegativeInteger(Chars, Len, Value)
1460 end;
1461 
xsdTryParseEnumnull1462 function xsdTryParseEnum(Chars: PChar; Len: Integer; enum: array of AnsiString; out Value: Integer): Boolean;
1463 var
1464   Temp: AnsiString;
1465   I: Integer;
1466 begin
1467   Temp := '';
1468   Result := xsdTryParseString(Chars, Len, Temp);
1469   if Result then
1470   begin
1471     for I := 0 to High(enum) do
1472       if Temp = enum[I] then
1473       begin
1474         Value := I;
1475         Exit(True);
1476       end;
1477     Result := False;
1478   end;
1479 end;
1480 
xsdParseStringDefnull1481 function xsdParseStringDef(Chars: PChar; Len: Integer; Default: AnsiString): AnsiString;
1482 begin
1483   if not xsdTryParseString(Chars, Len, Result) then
1484     Result := Default;
1485 end;
1486 
xsdParseStringLowerDefnull1487 function xsdParseStringLowerDef(Chars: PChar; Len: Integer; Default: AnsiString): AnsiString;
1488 begin
1489   if not xsdTryParseStringLower(Chars, Len, Result) then
1490     Result := Default;
1491 end;
1492 
xsdParseBooleanDefnull1493 function xsdParseBooleanDef(Chars: PChar; Len: Integer; Default: Boolean): Boolean;
1494 begin
1495   if not xsdTryParseBoolean(Chars, Len, Result) then
1496     Result := Default;
1497 end;
1498 
xsdParseDateDefnull1499 function xsdParseDateDef(Chars: PChar; Len: Integer; Default: TDateTime; Timezone: PXsdTimezone): TDateTime;
1500 begin
1501   if not xsdTryParseDate(Chars, Len, Result, Timezone) then
1502     Result := Default;
1503 end;
1504 
xsdParseTimeDefnull1505 function xsdParseTimeDef(Chars: PChar; Len: Integer; Default: TDateTime; Timezone: PXsdTimezone): TDateTime;
1506 begin
1507   if not xsdTryParseTime(Chars, Len, Result, Timezone) then
1508     Result := Default;
1509 end;
1510 
xsdParseDateTimeDefnull1511 function xsdParseDateTimeDef(Chars: PChar; Len: Integer; Default: TDateTime; Timezone: PXsdTimezone): TDateTime;
1512 begin
1513   if not xsdTryParseDateTime(Chars, Len, Result, Timezone) then
1514     Result := Default;
1515 end;
1516 
xsdParseDecimalDefnull1517 function xsdParseDecimalDef(Chars: PChar; Len: Integer; Default: Extended): Extended;
1518 begin
1519   if not xsdTryParseDecimal(Chars, Len, Result) then
1520     Result := Default;
1521 end;
1522 
xsdParseDoubleDefnull1523 function xsdParseDoubleDef(Chars: PChar; Len: Integer; Default: Double): Double;
1524 begin
1525   if not xsdTryParseDouble(Chars, Len, Result) then
1526     Result := Default;
1527 end;
1528 
xsdParseFloatDefnull1529 function xsdParseFloatDef(Chars: PChar; Len: Integer; Default: Single): Single;
1530 begin
1531   if not xsdTryParseFloat(Chars, Len, Result) then
1532     Result := Default;
1533 end;
1534 
xsdParseIntegerDefnull1535 function xsdParseIntegerDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
1536 begin
1537   if not xsdTryParseInteger(Chars, Len, Result) then
1538     Result := Default;
1539 end;
1540 
xsdParseNonNegativeIntegerDefnull1541 function xsdParseNonNegativeIntegerDef(Chars: PChar; Len: Integer; Default: QWord): QWord;
1542 begin
1543   if not xsdTryParseNonNegativeInteger(Chars, Len, Result) then
1544     Result := Default;
1545 end;
1546 
xsdParseNonPositiveIntegerDefnull1547 function xsdParseNonPositiveIntegerDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
1548 begin
1549   if not xsdTryParseNonPositiveInteger(Chars, Len, Result) then
1550     Result := Default;
1551 end;
1552 
xsdParseNegativeIntegerDefnull1553 function xsdParseNegativeIntegerDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
1554 begin
1555   if not xsdTryParseNegativeInteger(Chars, Len, Result) then
1556     Result := Default;
1557 end;
1558 
xsdParsePositiveIntegerDefnull1559 function xsdParsePositiveIntegerDef(Chars: PChar; Len: Integer; Default: QWord): QWord;
1560 begin
1561   if not xsdTryParsePositiveInteger(Chars, Len, Result) then
1562     Result := Default;
1563 end;
1564 
xsdParseByteDefnull1565 function xsdParseByteDef(Chars: PChar; Len: Integer; Default: Shortint): Shortint;
1566 begin
1567   if not xsdTryParseByte(Chars, Len, Result) then
1568     Result := Default;
1569 end;
1570 
xsdParseShortDefnull1571 function xsdParseShortDef(Chars: PChar; Len: Integer; Default: Smallint): Smallint;
1572 begin
1573   if not xsdTryParseShort(Chars, Len, Result) then
1574     Result := Default;
1575 end;
1576 
xsdParseIntDefnull1577 function xsdParseIntDef(Chars: PChar; Len: Integer; Default: Longint): Longint;
1578 begin
1579   if not xsdTryParseInt(Chars, Len, Result) then
1580     Result := Default;
1581 end;
1582 
xsdParseLongDefnull1583 function xsdParseLongDef(Chars: PChar; Len: Integer; Default: Int64): Int64;
1584 begin
1585   if not xsdTryParseLong(Chars, Len, Result) then
1586     Result := Default;
1587 end;
1588 
xsdParseUnsignedByteDefnull1589 function xsdParseUnsignedByteDef(Chars: PChar; Len: Integer; Default: Byte): Byte;
1590 begin
1591   if not xsdTryParseUnsignedByte(Chars, Len, Result) then
1592     Result := Default;
1593 end;
1594 
xsdParseUnsignedShortDefnull1595 function xsdParseUnsignedShortDef(Chars: PChar; Len: Integer; Default: Word): Word;
1596 begin
1597   if not xsdTryParseUnsignedShort(Chars, Len, Result) then
1598     Result := Default;
1599 end;
1600 
xsdParseUnsignedIntDefnull1601 function xsdParseUnsignedIntDef(Chars: PChar; Len: Integer; Default: Longword): Longword;
1602 begin
1603   if not xsdTryParseUnsignedInt(Chars, Len, Result) then
1604     Result := Default;
1605 end;
1606 
xsdParseUnsignedLongDefnull1607 function xsdParseUnsignedLongDef(Chars: PChar; Len: Integer; Default: QWord): QWord;
1608 begin
1609   if not xsdTryParseUnsignedLong(Chars, Len, Result) then
1610     Result := Default;
1611 end;
1612 
xsdParseEnumDefnull1613 function xsdParseEnumDef(Chars: PChar; Len: Integer; enum: array of AnsiString; Default: Integer): Integer;
1614 begin
1615   if not xsdTryParseEnum(Chars, Len, enum, Result) then
1616     Result := Default;
1617 end;
1618 
1619 procedure xsdParseBase64(Chars: PChar; Len: Integer; const Value: TStream);
1620 begin
1621   if not xsdTryParseBase64(Chars, Len, Value) then
1622     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:base64Binary']);
1623 end;
1624 
1625 procedure xsdParseString(Chars: PChar; Len: Integer; out Value: AnsiString);
1626 begin
1627   if not xsdTryParseString(Chars, Len, Value) then
1628     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:string']);
1629 end;
1630 
1631 procedure xsdParseStringLower(Chars: PChar; Len: Integer; out Value: AnsiString);
1632 begin
1633   if not xsdTryParseStringLower(Chars, Len, Value) then
1634     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:string']);
1635 end;
1636 
1637 procedure xsdParseBoolean(Chars: PChar; Len: Integer; out Value: Boolean);
1638 begin
1639   if not xsdTryParseBoolean(Chars, Len, Value) then
1640     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:boolean']);
1641 end;
1642 
1643 procedure xsdParseDate(Chars: PChar; Len: Integer; out Year, Month, Day: Longword; Timezone: PXsdTimezone; BC: PBoolean);
1644 begin
1645   if not xsdTryParseDate(Chars, Len, Year, Month, Day, Timezone, BC) then
1646     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:date']);
1647 end;
1648 
1649 procedure xsdParseDate(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone);
1650 begin
1651   if not xsdTryParseDate(Chars, Len, Value, Timezone) then
1652     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:date']);
1653 end;
1654 
1655 procedure xsdParseTime(Chars: PChar; Len: Integer; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone);
1656 begin
1657   if not xsdTryParseTime(Chars, Len, Hour, Minute, Second, Milliseconds, Timezone) then
1658     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:time']);
1659 end;
1660 
1661 procedure xsdParseTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone);
1662 begin
1663   if not xsdTryParseTime(Chars, Len, Value, Timezone) then
1664     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:time']);
1665 end;
1666 
1667 procedure xsdParseDateTime(Chars: PChar; Len: Integer; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone; BC: PBoolean);
1668 begin
1669   if not xsdTryParseDateTime(Chars, Len, Year, Month, Day, Hour, Minute, Second, Milliseconds, Timezone, BC) then
1670     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:dateTime']);
1671 end;
1672 
1673 procedure xsdParseDateTime(Chars: PChar; Len: Integer; out Value: TDateTime; Timezone: PXsdTimezone);
1674 begin
1675   if not xsdTryParseDateTime(Chars, Len, Value, Timezone) then
1676     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:dateTime']);
1677 end;
1678 
1679 procedure xsdParseDecimal(Chars: PChar; Len: Integer; out Value: Extended);
1680 begin
1681   if not xsdTryParseDecimal(Chars, Len, Value) then
1682     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:decimal']);
1683 end;
1684 
1685 procedure xsdParseDouble(Chars: PChar; Len: Integer; out Value: Double);
1686 begin
1687   if not xsdTryParseDouble(Chars, Len, Value) then
1688     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:double']);
1689 end;
1690 
1691 procedure xsdParseFloat(Chars: PChar; Len: Integer; out Value: Single);
1692 begin
1693   if not xsdTryParseFloat(Chars, Len, Value) then
1694     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:float']);
1695 end;
1696 
1697 procedure xsdParseInteger(Chars: PChar; Len: Integer; out Value: Int64);
1698 begin
1699   if not xsdTryParseInteger(Chars, Len, Value) then
1700     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:integer']);
1701 end;
1702 
1703 procedure xsdParseNonNegativeInteger(Chars: PChar; Len: Integer; out Value: QWord);
1704 begin
1705   if not xsdTryParseNonNegativeInteger(Chars, Len, Value) then
1706     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:nonNegativeInteger']);
1707 end;
1708 
1709 procedure xsdParseNonPositiveInteger(Chars: PChar; Len: Integer; out Value: Int64);
1710 begin
1711   if not xsdTryParseNonPositiveInteger(Chars, Len, Value) then
1712     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:nonPositiveInteger']);
1713 end;
1714 
1715 procedure xsdParseNegativeInteger(Chars: PChar; Len: Integer; out Value: Int64);
1716 begin
1717   if not xsdTryParseNegativeInteger(Chars, Len, Value) then
1718     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:negativeInteger']);
1719 end;
1720 
1721 procedure xsdParsePositiveInteger(Chars: PChar; Len: Integer; out Value: QWord);
1722 begin
1723   if not xsdTryParsePositiveInteger(Chars, Len, Value) then
1724     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:positiveInteger']);
1725 end;
1726 
1727 procedure xsdParseByte(Chars: PChar; Len: Integer; out Value: Shortint);
1728 begin
1729   if not xsdTryParseByte(Chars, Len, Value) then
1730     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:byte']);
1731 end;
1732 
1733 procedure xsdParseShort(Chars: PChar; Len: Integer; out Value: Smallint);
1734 begin
1735   if not xsdTryParseShort(Chars, Len, Value) then
1736     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:short']);
1737 end;
1738 
1739 procedure xsdParseInt(Chars: PChar; Len: Integer; out Value: Longint);
1740 begin
1741   if not xsdTryParseInt(Chars, Len, Value) then
1742     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:int']);
1743 end;
1744 
1745 procedure xsdParseLong(Chars: PChar; Len: Integer; out Value: Int64);
1746 begin
1747   if not xsdTryParseLong(Chars, Len, Value) then
1748     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:long']);
1749 end;
1750 
1751 procedure xsdParseUnsignedByte(Chars: PChar; Len: Integer; out Value: Byte);
1752 begin
1753   if not xsdTryParseUnsignedByte(Chars, Len, Value) then
1754     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:unsignedByte']);
1755 end;
1756 
1757 procedure xsdParseUnsignedShort(Chars: PChar; Len: Integer; out Value: Word);
1758 begin
1759   if not xsdTryParseUnsignedShort(Chars, Len, Value) then
1760     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:unsignedShort']);
1761 end;
1762 
1763 procedure xsdParseUnsignedInt(Chars: PChar; Len: Integer; out Value: Longword);
1764 begin
1765   if not xsdTryParseUnsignedInt(Chars, Len, Value) then
1766     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:unsignedInt']);
1767 end;
1768 
1769 procedure xsdParseUnsignedLong(Chars: PChar; Len: Integer; out Value: QWord);
1770 begin
1771   if not xsdTryParseUnsignedLong(Chars, Len, Value) then
1772     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:unsignedLong']);
1773 end;
1774 
1775 procedure xsdParseEnum(Chars: PChar; Len: Integer; enum: array of AnsiString; out Value: Integer);
1776 begin
1777   if not xsdTryParseEnum(Chars, Len, enum, Value) then
1778     raise EConvertError.CreateFmt(SXsdParserError, [__strpas(Chars,Len), 'xs:enum']);
1779 end;
1780 
xsdParseStringnull1781 function xsdParseString(Chars: PChar; Len: Integer): AnsiString;
1782 begin
1783   xsdParseString(Chars, Len, Result);
1784 end;
1785 
xsdParseStringLowernull1786 function xsdParseStringLower(Chars: PChar; Len: Integer): AnsiString;
1787 begin
1788   xsdParseStringLower(Chars, Len, Result);
1789 end;
1790 
xsdParseBooleannull1791 function xsdParseBoolean(Chars: PChar; Len: Integer): Boolean;
1792 begin
1793   xsdParseBoolean(Chars, Len, Result);
1794 end;
1795 
xsdParseDatenull1796 function xsdParseDate(Chars: PChar; Len: Integer; Timezone: PXsdTimezone): TDateTime;
1797 begin
1798   xsdParseDate(Chars, Len, Result, Timezone);
1799 end;
1800 
xsdParseTimenull1801 function xsdParseTime(Chars: PChar; Len: Integer; Timezone: PXsdTimezone): TDateTime;
1802 begin
1803   xsdParseTime(Chars, Len, Result, Timezone);
1804 end;
1805 
xsdParseDateTimenull1806 function xsdParseDateTime(Chars: PChar; Len: Integer; Timezone: PXsdTimezone): TDateTime;
1807 begin
1808   xsdParseDateTime(Chars, Len, Result, Timezone);
1809 end;
1810 
xsdParseDecimalnull1811 function xsdParseDecimal(Chars: PChar; Len: Integer): Extended;
1812 begin
1813   xsdParseDecimal(Chars, Len, Result);
1814 end;
1815 
xsdParseDoublenull1816 function xsdParseDouble(Chars: PChar; Len: Integer): Double;
1817 begin
1818   xsdParseDouble(Chars, Len, Result);
1819 end;
1820 
xsdParseFloatnull1821 function xsdParseFloat(Chars: PChar; Len: Integer): Single;
1822 begin
1823   xsdParseFloat(Chars, Len, Result);
1824 end;
1825 
xsdParseIntegernull1826 function xsdParseInteger(Chars: PChar; Len: Integer): Int64;
1827 begin
1828   xsdParseInteger(Chars, Len, Result);
1829 end;
1830 
xsdParseNonNegativeIntegernull1831 function xsdParseNonNegativeInteger(Chars: PChar; Len: Integer): QWord;
1832 begin
1833   xsdParseNonNegativeInteger(Chars, Len, Result);
1834 end;
1835 
xsdParseNonPositiveIntegernull1836 function xsdParseNonPositiveInteger(Chars: PChar; Len: Integer): Int64;
1837 begin
1838   xsdParseNonPositiveInteger(Chars, Len, Result);
1839 end;
1840 
xsdParseNegativeIntegernull1841 function xsdParseNegativeInteger(Chars: PChar; Len: Integer): Int64;
1842 begin
1843   xsdParseNegativeInteger(Chars, Len, Result);
1844 end;
1845 
xsdParsePositiveIntegernull1846 function xsdParsePositiveInteger(Chars: PChar; Len: Integer): QWord;
1847 begin
1848   xsdParsePositiveInteger(Chars, Len, Result);
1849 end;
1850 
xsdParseBytenull1851 function xsdParseByte(Chars: PChar; Len: Integer): Shortint;
1852 begin
1853   xsdParseByte(Chars, Len, Result);
1854 end;
1855 
xsdParseShortnull1856 function xsdParseShort(Chars: PChar; Len: Integer): Smallint;
1857 begin
1858   xsdParseShort(Chars, Len, Result);
1859 end;
1860 
xsdParseIntnull1861 function xsdParseInt(Chars: PChar; Len: Integer): Longint;
1862 begin
1863   xsdParseInt(Chars, Len, Result);
1864 end;
1865 
xsdParseLongnull1866 function xsdParseLong(Chars: PChar; Len: Integer): Int64;
1867 begin
1868   xsdParseLong(Chars, Len, Result);
1869 end;
1870 
xsdParseUnsignedBytenull1871 function xsdParseUnsignedByte(Chars: PChar; Len: Integer): Byte;
1872 begin
1873   xsdParseUnsignedByte(Chars, Len, Result);
1874 end;
1875 
xsdParseUnsignedShortnull1876 function xsdParseUnsignedShort(Chars: PChar; Len: Integer): Word;
1877 begin
1878   xsdParseUnsignedShort(Chars, Len, Result);
1879 end;
1880 
xsdParseUnsignedIntnull1881 function xsdParseUnsignedInt(Chars: PChar; Len: Integer): Longword;
1882 begin
1883   xsdParseUnsignedInt(Chars, Len, Result);
1884 end;
1885 
xsdParseUnsignedLongnull1886 function xsdParseUnsignedLong(Chars: PChar; Len: Integer): QWord;
1887 begin
1888   xsdParseUnsignedLong(Chars, Len, Result);
1889 end;
1890 
xsdParseEnumnull1891 function xsdParseEnum(Chars: PChar; Len: Integer; enum: array of AnsiString): Integer;
1892 begin
1893   xsdParseEnum(Chars, Len, enum, Result);
1894 end;
1895 (*
1896 function xsdTryParseBase64(const S: AnsiString; const Value: TStream): Boolean;
1897 begin
1898 
1899 end;
1900 
1901 function xsdTryParseString(const S: AnsiString; out Value: AnsiString): Boolean;
1902 begin
1903 
1904 end;
1905 
1906 function xsdTryParseStringLower(const S: AnsiString; out Value: AnsiString
1907   ): Boolean;
1908 begin
1909 
1910 end;
1911 
1912 function xsdTryParseBoolean(const S: AnsiString; out Value: Boolean): Boolean;
1913 begin
1914 
1915 end;
1916 
1917 function xsdTryParseDate(const S: AnsiString; out Year, Month, Day: Longword;
1918   Timezone: PXsdTimezone; BC: PBoolean): Boolean;
1919 begin
1920 
1921 end;
1922 
1923 function xsdTryParseDate(const S: AnsiString; out Value: TDateTime;
1924   Timezone: PXsdTimezone): Boolean;
1925 begin
1926 
1927 end;
1928 
1929 function xsdTryParseTime(const S: AnsiString; out Hour, Minute, Second,
1930   Milliseconds: Longword; Timezone: PXsdTimezone): Boolean;
1931 begin
1932 
1933 end;
1934 
1935 function xsdTryParseTime(const S: AnsiString; out Value: TDateTime;
1936   Timezone: PXsdTimezone): Boolean;
1937 begin
1938 
1939 end;
1940 
1941 function xsdTryParseDateTime(const S: AnsiString; out Year, Month, Day, Hour,
1942   Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone; BC: PBoolean
1943   ): Boolean;
1944 begin
1945 
1946 end;
1947 
1948 function xsdTryParseDateTime(const S: AnsiString; out Value: TDateTime;
1949   Timezone: PXsdTimezone): Boolean;
1950 begin
1951 
1952 end;
1953 
1954 function xsdTryParseDecimal(const S: AnsiString; out Value: Extended): Boolean;
1955 begin
1956 
1957 end;
1958 
1959 function xsdTryParseDouble(const S: AnsiString; out Value: Double): Boolean;
1960 begin
1961 
1962 end;
1963 
1964 function xsdTryParseFloat(const S: AnsiString; out Value: Single): Boolean;
1965 begin
1966 
1967 end;
1968 
1969 function xsdTryParseInteger(const S: AnsiString; out Value: Int64): Boolean;
1970 begin
1971 
1972 end;
1973 
1974 function xsdTryParseNonNegativeInteger(const S: AnsiString; out Value: QWord
1975   ): Boolean;
1976 begin
1977 
1978 end;
1979 
1980 function xsdTryParseNonPositiveInteger(const S: AnsiString; out Value: Int64
1981   ): Boolean;
1982 begin
1983 
1984 end;
1985 
1986 function xsdTryParseNegativeInteger(const S: AnsiString; out Value: Int64
1987   ): Boolean;
1988 begin
1989 
1990 end;
1991 
1992 function xsdTryParsePositiveInteger(const S: AnsiString; out Value: QWord
1993   ): Boolean;
1994 begin
1995 
1996 end;
1997 
1998 function xsdTryParseByte(const S: AnsiString; out Value: Shortint): Boolean;
1999 begin
2000 
2001 end;
2002 
2003 function xsdTryParseShort(const S: AnsiString; out Value: Smallint): Boolean;
2004 begin
2005 
2006 end;
2007 
2008 function xsdTryParseInt(const S: AnsiString; out Value: Longint): Boolean;
2009 begin
2010 
2011 end;
2012 
2013 function xsdTryParseLong(const S: AnsiString; out Value: Int64): Boolean;
2014 begin
2015 
2016 end;
2017 
2018 function xsdTryParseUnsignedByte(const S: AnsiString; out Value: Byte): Boolean;
2019 begin
2020 
2021 end;
2022 
2023 function xsdTryParseUnsignedShort(const S: AnsiString; out Value: Word
2024   ): Boolean;
2025 begin
2026 
2027 end;
2028 
2029 function xsdTryParseUnsignedInt(const S: AnsiString; out Value: Longword
2030   ): Boolean;
2031 begin
2032 
2033 end;
2034 
2035 function xsdTryParseUnsignedLong(const S: AnsiString; out Value: QWord
2036   ): Boolean;
2037 begin
2038 
2039 end;
2040 
2041 function xsdTryParseEnum(const S: AnsiString; enum: array of AnsiString;
2042   out Value: Integer): Boolean;
2043 begin
2044 
2045 end;
2046 
2047 function xsdParseStringDef(const S: AnsiString; Default: AnsiString
2048   ): AnsiString;
2049 begin
2050 
2051 end;
2052 
2053 function xsdParseStringLowerDef(const S: AnsiString; Default: AnsiString
2054   ): AnsiString;
2055 begin
2056 
2057 end;
2058 
2059 function xsdParseBooleanDef(const S: AnsiString; Default: Boolean): Boolean;
2060 begin
2061 
2062 end;
2063 
2064 function xsdParseDateDef(const S: AnsiString; Default: TDateTime;
2065   Timezone: PXsdTimezone): TDateTime;
2066 begin
2067 
2068 end;
2069 
2070 function xsdParseTimeDef(const S: AnsiString; Default: TDateTime;
2071   Timezone: PXsdTimezone): TDateTime;
2072 begin
2073 
2074 end;
2075 
2076 function xsdParseDateTimeDef(const S: AnsiString; Default: TDateTime;
2077   Timezone: PXsdTimezone): TDateTime;
2078 begin
2079 
2080 end;
2081 
2082 function xsdParseDecimalDef(const S: AnsiString; Default: Extended): Extended;
2083 begin
2084 
2085 end;
2086 
2087 function xsdParseDoubleDef(const S: AnsiString; Default: Double): Double;
2088 begin
2089 
2090 end;
2091 
2092 function xsdParseFloatDef(const S: AnsiString; Default: Single): Single;
2093 begin
2094 
2095 end;
2096 
2097 function xsdParseIntegerDef(const S: AnsiString; Default: Int64): Int64;
2098 begin
2099 
2100 end;
2101 
2102 function xsdParseNonNegativeIntegerDef(const S: AnsiString; Default: QWord
2103   ): QWord;
2104 begin
2105 
2106 end;
2107 
2108 function xsdParseNonPositiveIntegerDef(const S: AnsiString; Default: Int64
2109   ): Int64;
2110 begin
2111 
2112 end;
2113 
2114 function xsdParseNegativeIntegerDef(const S: AnsiString; Default: Int64): Int64;
2115 begin
2116 
2117 end;
2118 
2119 function xsdParsePositiveIntegerDef(const S: AnsiString; Default: QWord): QWord;
2120 begin
2121 
2122 end;
2123 
2124 function xsdParseByteDef(const S: AnsiString; Default: Shortint): Shortint;
2125 begin
2126 
2127 end;
2128 
2129 function xsdParseShortDef(const S: AnsiString; Default: Smallint): Smallint;
2130 begin
2131 
2132 end;
2133 
2134 function xsdParseIntDef(const S: AnsiString; Default: Longint): Longint;
2135 begin
2136 
2137 end;
2138 
2139 function xsdParseLongDef(const S: AnsiString; Default: Int64): Int64;
2140 begin
2141 
2142 end;
2143 
2144 function xsdParseUnsignedByteDef(const S: AnsiString; Default: Byte): Byte;
2145 begin
2146 
2147 end;
2148 
2149 function xsdParseUnsignedShortDef(const S: AnsiString; Default: Word): Word;
2150 begin
2151 
2152 end;
2153 
2154 function xsdParseUnsignedIntDef(const S: AnsiString; Default: Longword
2155   ): Longword;
2156 begin
2157 
2158 end;
2159 
2160 function xsdParseUnsignedLongDef(const S: AnsiString; Default: QWord): QWord;
2161 begin
2162 
2163 end;
2164 
2165 function xsdParseEnumDef(const S: AnsiString; enum: array of AnsiString;
2166   Default: Integer): Integer;
2167 begin
2168 
2169 end;*)
2170 
2171 procedure xsdParseBase64(const S: AnsiString; const Value: TStream);
2172 begin
2173   xsdParseBase64(PChar(S), Length(S), Value);
2174 end;
2175 
2176 procedure xsdParseString(const S: AnsiString; out Value: AnsiString);
2177 begin
2178   xsdParseString(PChar(S), Length(S), Value);
2179 end;
2180 
2181 procedure xsdParseStringLower(const S: AnsiString; out Value: AnsiString);
2182 begin
2183   xsdParseStringLower(PChar(S), Length(S), Value);
2184 end;
2185 
2186 procedure xsdParseBoolean(const S: AnsiString; out Value: Boolean);
2187 begin
2188   xsdParseBoolean(PChar(S), Length(S), Value);
2189 end;
2190 
2191 procedure xsdParseDate(const S: AnsiString; out Year, Month, Day: Longword;
2192   Timezone: PXsdTimezone; BC: PBoolean);
2193 begin
2194   xsdParseDate(PChar(S), Length(S), Year, Month, Day, Timezone, BC);
2195 end;
2196 
2197 procedure xsdParseDate(const S: AnsiString; out Value: TDateTime;
2198   Timezone: PXsdTimezone);
2199 begin
2200   xsdParseDate(PChar(S), Length(S), Value);
2201 end;
2202 
2203 procedure xsdParseTime(const S: AnsiString; out Hour, Minute, Second,
2204   Milliseconds: Longword; Timezone: PXsdTimezone);
2205 begin
2206   xsdParseTime(PChar(S), Length(S), Hour, Minute, Second,
2207     Milliseconds, Timezone);
2208 end;
2209 
2210 procedure xsdParseTime(const S: AnsiString; out Value: TDateTime;
2211   Timezone: PXsdTimezone);
2212 begin
2213   xsdParseTime(PChar(S), Length(S), Value, Timezone);
2214 end;
2215 
2216 procedure xsdParseDateTime(const S: AnsiString; out Year, Month, Day, Hour,
2217   Minute, Second, Milliseconds: Longword; Timezone: PXsdTimezone; BC: PBoolean);
2218 begin
2219   xsdParseDateTime(PChar(S), Length(S), Year, Month, Day, Hour,
2220     Minute, Second, Milliseconds, Timezone, BC);
2221 end;
2222 
2223 procedure xsdParseDateTime(const S: AnsiString; out Value: TDateTime;
2224   Timezone: PXsdTimezone);
2225 begin
2226   xsdParseDateTime(PChar(S), Length(S), Value);
2227 end;
2228 
2229 procedure xsdParseDecimal(const S: AnsiString; out Value: Extended);
2230 begin
2231   xsdParseDecimal(PChar(S), Length(S), Value);
2232 end;
2233 
2234 procedure xsdParseDouble(const S: AnsiString; out Value: Double);
2235 begin
2236   xsdParseDouble(PChar(S), Length(S), Value);
2237 end;
2238 
2239 procedure xsdParseFloat(const S: AnsiString; out Value: Single);
2240 begin
2241   xsdParseFloat(PChar(S), Length(S), Value);
2242 end;
2243 
2244 procedure xsdParseInteger(const S: AnsiString; out Value: Int64);
2245 begin
2246   xsdParseInteger(PChar(S), Length(S), Value);
2247 end;
2248 
2249 procedure xsdParseNonNegativeInteger(const S: AnsiString; out Value: QWord);
2250 begin
2251   xsdParseNonNegativeInteger(PChar(S), Length(S), Value);
2252 end;
2253 
2254 procedure xsdParseNonPositiveInteger(const S: AnsiString; out Value: Int64);
2255 begin
2256   xsdParseNonPositiveInteger(PChar(S), Length(S), Value);
2257 end;
2258 
2259 procedure xsdParseNegativeInteger(const S: AnsiString; out Value: Int64);
2260 begin
2261   xsdParseNegativeInteger(PChar(S), Length(S), Value);
2262 end;
2263 
2264 procedure xsdParsePositiveInteger(const S: AnsiString; out Value: QWord);
2265 begin
2266   xsdParsePositiveInteger(PChar(S), Length(S), Value);
2267 end;
2268 
2269 procedure xsdParseByte(const S: AnsiString; out Value: Shortint);
2270 begin
2271   xsdParseByte(PChar(S), Length(S), Value);
2272 end;
2273 
2274 procedure xsdParseShort(const S: AnsiString; out Value: Smallint);
2275 begin
2276   xsdParseShort(PChar(S), Length(S), Value);
2277 end;
2278 
2279 procedure xsdParseInt(const S: AnsiString; out Value: Longint);
2280 begin
2281   xsdParseInt(PChar(S), Length(S), Value);
2282 end;
2283 
2284 procedure xsdParseLong(const S: AnsiString; out Value: Int64);
2285 begin
2286   xsdParseLong(PChar(S), Length(S), Value);
2287 end;
2288 
2289 procedure xsdParseUnsignedByte(const S: AnsiString; out Value: Byte);
2290 begin
2291   xsdParseUnsignedByte(PChar(S), Length(S), Value);
2292 end;
2293 
2294 procedure xsdParseUnsignedShort(const S: AnsiString; out Value: Word);
2295 begin
2296   xsdParseUnsignedShort(PChar(S), Length(S), Value);
2297 end;
2298 
2299 procedure xsdParseUnsignedInt(const S: AnsiString; out Value: Longword);
2300 begin
2301   xsdParseUnsignedInt(PChar(S), Length(S), Value);
2302 end;
2303 
2304 procedure xsdParseUnsignedLong(const S: AnsiString; out Value: QWord);
2305 begin
2306   xsdParseUnsignedLong(PChar(S), Length(S), Value);
2307 end;
2308 
2309 procedure xsdParseEnum(const S: AnsiString; enum: array of AnsiString; out Value: Integer);
2310 begin
2311   xsdParseEnum(PChar(S), Length(S), enum, Value);
2312 end;
2313 
xsdParseStringnull2314 function xsdParseString(const S: AnsiString): AnsiString;
2315 begin
2316   xsdParseString(PChar(S), Length(S), Result);
2317 end;
2318 
xsdParseStringLowernull2319 function xsdParseStringLower(const S: AnsiString): AnsiString;
2320 begin
2321   xsdParseStringLower(PChar(S), Length(S), Result);
2322 end;
2323 
xsdParseBooleannull2324 function xsdParseBoolean(const S: AnsiString): Boolean;
2325 begin
2326   xsdParseBoolean(PChar(S), Length(S), Result);
2327 end;
2328 
xsdParseDatenull2329 function xsdParseDate(const S: AnsiString; Timezone: PXsdTimezone): TDateTime;
2330 begin
2331   xsdParseDate(PChar(S), Length(S), Result, Timezone);
2332 end;
2333 
xsdParseTimenull2334 function xsdParseTime(const S: AnsiString; Timezone: PXsdTimezone): TDateTime;
2335 begin
2336   xsdParseTime(PChar(S), Length(S), Result, Timezone);
2337 end;
2338 
xsdParseDateTimenull2339 function xsdParseDateTime(const S: AnsiString; Timezone: PXsdTimezone): TDateTime;
2340 begin
2341   xsdParseDateTime(PChar(S), Length(S), Result, Timezone);
2342 end;
2343 
xsdParseDecimalnull2344 function xsdParseDecimal(const S: AnsiString): Extended;
2345 begin
2346   xsdParseDecimal(PChar(S), Length(S), Result);
2347 end;
2348 
xsdParseDoublenull2349 function xsdParseDouble(const S: AnsiString): Double;
2350 begin
2351   xsdParseDouble(PChar(S), Length(S), Result);
2352 end;
2353 
xsdParseFloatnull2354 function xsdParseFloat(const S: AnsiString): Single;
2355 begin
2356   xsdParseFloat(PChar(S), Length(S), Result);
2357 end;
2358 
xsdParseIntegernull2359 function xsdParseInteger(const S: AnsiString): Int64;
2360 begin
2361   xsdParseInteger(PChar(S), Length(S), Result);
2362 end;
2363 
xsdParseNonNegativeIntegernull2364 function xsdParseNonNegativeInteger(const S: AnsiString): QWord;
2365 begin
2366   xsdParseNonNegativeInteger(PChar(S), Length(S), Result);
2367 end;
2368 
xsdParseNonPositiveIntegernull2369 function xsdParseNonPositiveInteger(const S: AnsiString): Int64;
2370 begin
2371   xsdParseNonPositiveInteger(PChar(S), Length(S), Result);
2372 end;
2373 
xsdParseNegativeIntegernull2374 function xsdParseNegativeInteger(const S: AnsiString): Int64;
2375 begin
2376   xsdParseNegativeInteger(PChar(S), Length(S), Result);
2377 end;
2378 
xsdParsePositiveIntegernull2379 function xsdParsePositiveInteger(const S: AnsiString): QWord;
2380 begin
2381   xsdParsePositiveInteger(PChar(S), Length(S), Result);
2382 end;
2383 
xsdParseBytenull2384 function xsdParseByte(const S: AnsiString): Shortint;
2385 begin
2386   xsdParseByte(PChar(S), Length(S), Result);
2387 end;
2388 
xsdParseShortnull2389 function xsdParseShort(const S: AnsiString): Smallint;
2390 begin
2391   xsdParseShort(PChar(S), Length(S), Result);
2392 end;
2393 
xsdParseIntnull2394 function xsdParseInt(const S: AnsiString): Longint;
2395 begin
2396   xsdParseInt(PChar(S), Length(S), Result);
2397 end;
2398 
xsdParseLongnull2399 function xsdParseLong(const S: AnsiString): Int64;
2400 begin
2401   xsdParseLong(PChar(S), Length(S), Result);
2402 end;
2403 
xsdParseUnsignedBytenull2404 function xsdParseUnsignedByte(const S: AnsiString): Byte;
2405 begin
2406   xsdParseUnsignedByte(PChar(S), Length(S), Result);
2407 end;
2408 
xsdParseUnsignedShortnull2409 function xsdParseUnsignedShort(const S: AnsiString): Word;
2410 begin
2411   xsdParseUnsignedShort(PChar(S), Length(S), Result);
2412 end;
2413 
xsdParseUnsignedIntnull2414 function xsdParseUnsignedInt(const S: AnsiString): Longword;
2415 begin
2416   xsdParseUnsignedInt(PChar(S), Length(S), Result);
2417 end;
2418 
xsdParseUnsignedLongnull2419 function xsdParseUnsignedLong(const S: AnsiString): QWord;
2420 begin
2421   xsdParseUnsignedLong(PChar(S), Length(S), Result);
2422 end;
2423 
xsdParseEnumnull2424 function xsdParseEnum(const S: AnsiString; enum: array of AnsiString): Integer;
2425 begin
2426   xsdParseEnum(PChar(S), Length(S), enum, Result);
2427 end;
2428 
2429 end.
2430