xmlxsd.pas 109 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811
  1. {
  2. A set of helper functions for libxml2 for FreePascal
  3. Copyright (C) 2008 by Ivo Steinmann
  4. }
  5. unit xmlxsd;
  6. {$mode objfpc}
  7. {$H+}
  8. interface
  9. uses
  10. ctypes,
  11. xml2,
  12. Math,
  13. DateUtils,
  14. SysUtils;
  15. resourcestring
  16. ParserError = 'parsing "%s" as "%s" failed';
  17. ChildNotFound = 'child %s not found';
  18. PropNotFound = 'attribute %s not found';
  19. const
  20. IGNORE_LAST = Pointer(-1);
  21. type
  22. XSDException = class(Exception)
  23. public
  24. constructor CreateNode(const Msg: String; name, nameSpace: xmlCharPtr);
  25. end;
  26. TTimezoneType = (
  27. tzUnknown,
  28. tzUTC,
  29. tzUser
  30. );
  31. PTimezone = ^TTimezone;
  32. TTimezone = record
  33. Kind : TTimezoneType;
  34. Hour : Longint; // +/- [00..23]
  35. Minute : Longword; // [00..59]
  36. Convert: Boolean; // you have to initialize this field allways!!!
  37. end;
  38. const
  39. TIMEZONE_UTC: TTimezone = (Kind:tzUTC;Hour:0;Minute:0;Convert:False);
  40. TIMEZONE_UNKNOWN: TTimezone = (Kind:tzUnknown;Hour:0;Minute:0;Convert:False);
  41. CONVERT_TO_TIMEZONE_UTC: TTimezone = (Kind:tzUTC;Hour:0;Minute:0;Convert:True);
  42. { Format functions }
  43. function xsdFormatBoolean(Value: Boolean; UseWords: Boolean = False): Utf8String;
  44. function xsdFormatDate(Year, Month, Day: Longword; BC: Boolean; Timezone: PTimezone = nil): Utf8String;
  45. function xsdFormatDate(Value: TDateTime; Timezone: PTimezone = nil): Utf8String;
  46. function xsdFormatTime(Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil): Utf8String;
  47. function xsdFormatTime(Value: TDateTime; Timezone: PTimezone = nil): Utf8String;
  48. function xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; BC: Boolean; Timezone: PTimezone = nil): Utf8String;
  49. function xsdFormatDateTime(Value: TDateTime; Timezone: PTimezone): Utf8String;
  50. function xsdFormatDecimal(Value: Extended; Precision: Integer = 4; Digits: Integer = 1): Utf8String;
  51. function xsdFormatDouble(Value: Double): Utf8String;
  52. function xsdFormatFloat(Value: Single): Utf8String;
  53. function xsdFormatByte(Value: Shortint): Utf8String;
  54. function xsdFormatShort(Value: Smallint): Utf8String;
  55. function xsdFormatInt(Value: Longint): Utf8String;
  56. function xsdFormatLong(Value: Int64): Utf8String;
  57. function xsdFormatUnsignedByte(Value: Byte): Utf8String;
  58. function xsdFormatUnsignedShort(Value: Word): Utf8String;
  59. function xsdFormatUnsignedInt(Value: Longword): Utf8String;
  60. function xsdFormatUnsignedLong(Value: QWord): Utf8String;
  61. function xsdFormatEnum(enum: array of Utf8String; Value: Integer): Utf8String;
  62. { DateTime functions }
  63. procedure xsdTimeConvertTo(var Hour, Minute, Second, Milliseconds: Longword; const Current, Target: TTimezone);
  64. procedure xsdDateConvertTo(var Year, Month, Day: Longword; const Current, Target: TTimezone);
  65. procedure xsdDateTimeConvertTo(var Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; const Current, Target: TTimezone);
  66. { Parse functions }
  67. function xsdTryParseString(Chars: xmlCharPtr; Len: Integer; out Value: Utf8String): Boolean;
  68. function xsdTryParseStringLower(Chars: xmlCharPtr; Len: Integer; out Value: Utf8String): Boolean;
  69. function xsdTryParseBoolean(Chars: xmlCharPtr; Len: Integer; out Value: Boolean): Boolean;
  70. function xsdTryParseDate(Chars: xmlCharPtr; Len: Integer; out Year, Month, Day: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil): Boolean;
  71. function xsdTryParseDate(Chars: xmlCharPtr; Len: Integer; out Value: TDateTime; Timezone: PTimezone = nil): Boolean;
  72. function xsdTryParseTime(Chars: xmlCharPtr; Len: Integer; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil): Boolean;
  73. function xsdTryParseTime(Chars: xmlCharPtr; Len: Integer; out Value: TDateTime; Timezone: PTimezone = nil): Boolean;
  74. function xsdTryParseDateTime(Chars: xmlCharPtr; Len: Integer; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil): Boolean;
  75. function xsdTryParseDateTime(Chars: xmlCharPtr; Len: Integer; out Value: TDateTime; Timezone: PTimezone = nil): Boolean;
  76. function xsdTryParseDecimal(Chars: xmlCharPtr; Len: Integer; out Value: Extended): Boolean;
  77. function xsdTryParseDouble(Chars: xmlCharPtr; Len: Integer; out Value: Double): Boolean;
  78. function xsdTryParseFloat(Chars: xmlCharPtr; Len: Integer; out Value: Single): Boolean;
  79. function xsdTryParseInteger(Chars: xmlCharPtr; Len: Integer; out Value: Int64): Boolean;
  80. function xsdTryParseNonNegativeInteger(Chars: xmlCharPtr; Len: Integer; out Value: QWord): Boolean;
  81. function xsdTryParseNonPositiveInteger(Chars: xmlCharPtr; Len: Integer; out Value: Int64): Boolean;
  82. function xsdTryParseNegativeInteger(Chars: xmlCharPtr; Len: Integer; out Value: Int64): Boolean;
  83. function xsdTryParsePositiveInteger(Chars: xmlCharPtr; Len: Integer; out Value: QWord): Boolean;
  84. function xsdTryParseByte(Chars: xmlCharPtr; Len: Integer; out Value: Shortint): Boolean;
  85. function xsdTryParseShort(Chars: xmlCharPtr; Len: Integer; out Value: Smallint): Boolean;
  86. function xsdTryParseInt(Chars: xmlCharPtr; Len: Integer; out Value: Longint): Boolean;
  87. function xsdTryParseLong(Chars: xmlCharPtr; Len: Integer; out Value: Int64): Boolean;
  88. function xsdTryParseUnsignedByte(Chars: xmlCharPtr; Len: Integer; out Value: Byte): Boolean;
  89. function xsdTryParseUnsignedShort(Chars: xmlCharPtr; Len: Integer; out Value: Word): Boolean;
  90. function xsdTryParseUnsignedInt(Chars: xmlCharPtr; Len: Integer; out Value: Longword): Boolean;
  91. function xsdTryParseUnsignedLong(Chars: xmlCharPtr; Len: Integer; out Value: QWord): Boolean;
  92. function xsdTryParseEnum(Chars: xmlCharPtr; Len: Integer; enum: array of Utf8String; out Value: Integer): Boolean;
  93. function xsdParseStringDef(Chars: xmlCharPtr; Len: Integer; Default: Utf8String): Utf8String;
  94. function xsdParseStringLowerDef(Chars: xmlCharPtr; Len: Integer; Default: Utf8String): Utf8String;
  95. function xsdParseBooleanDef(Chars: xmlCharPtr; Len: Integer; Default: Boolean): Boolean;
  96. function xsdParseDateDef(Chars: xmlCharPtr; Len: Integer; Default: TDateTime; Timezone: PTimezone = nil): TDateTime;
  97. function xsdParseTimeDef(Chars: xmlCharPtr; Len: Integer; Default: TDateTime; Timezone: PTimezone = nil): TDateTime;
  98. function xsdParseDateTimeDef(Chars: xmlCharPtr; Len: Integer; Default: TDateTime; Timezone: PTimezone = nil): TDateTime;
  99. function xsdParseDecimalDef(Chars: xmlCharPtr; Len: Integer; Default: Extended): Extended;
  100. function xsdParseDoubleDef(Chars: xmlCharPtr; Len: Integer; Default: Double): Double;
  101. function xsdParseFloatDef(Chars: xmlCharPtr; Len: Integer; Default: Single): Single;
  102. function xsdParseIntegerDef(Chars: xmlCharPtr; Len: Integer; Default: Int64): Int64;
  103. function xsdParseNonNegativeIntegerDef(Chars: xmlCharPtr; Len: Integer; Default: QWord): QWord;
  104. function xsdParseNonPositiveIntegerDef(Chars: xmlCharPtr; Len: Integer; Default: Int64): Int64;
  105. function xsdParseNegativeIntegerDef(Chars: xmlCharPtr; Len: Integer; Default: Int64): Int64;
  106. function xsdParsePositiveIntegerDef(Chars: xmlCharPtr; Len: Integer; Default: QWord): QWord;
  107. function xsdParseByteDef(Chars: xmlCharPtr; Len: Integer; Default: Shortint): Shortint;
  108. function xsdParseShortDef(Chars: xmlCharPtr; Len: Integer; Default: Smallint): Smallint;
  109. function xsdParseIntDef(Chars: xmlCharPtr; Len: Integer; Default: Longint): Longint;
  110. function xsdParseLongDef(Chars: xmlCharPtr; Len: Integer; Default: Int64): Int64;
  111. function xsdParseUnsignedByteDef(Chars: xmlCharPtr; Len: Integer; Default: Byte): Byte;
  112. function xsdParseUnsignedShortDef(Chars: xmlCharPtr; Len: Integer; Default: Word): Word;
  113. function xsdParseUnsignedIntDef(Chars: xmlCharPtr; Len: Integer; Default: Longword): Longword;
  114. function xsdParseUnsignedLongDef(Chars: xmlCharPtr; Len: Integer; Default: QWord): QWord;
  115. function xsdParseEnumDef(Chars: xmlCharPtr; Len: Integer; enum: array of Utf8String; Default: Integer): Integer;
  116. procedure xsdParseString(Chars: xmlCharPtr; Len: Integer; out Value: Utf8String);
  117. procedure xsdParseStringLower(Chars: xmlCharPtr; Len: Integer; out Value: Utf8String);
  118. procedure xsdParseBoolean(Chars: xmlCharPtr; Len: Integer; out Value: Boolean);
  119. procedure xsdParseDate(Chars: xmlCharPtr; Len: Integer; out Year, Month, Day: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil);
  120. procedure xsdParseDate(Chars: xmlCharPtr; Len: Integer; out Value: TDateTime; Timezone: PTimezone = nil);
  121. procedure xsdParseTime(Chars: xmlCharPtr; Len: Integer; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil);
  122. procedure xsdParseTime(Chars: xmlCharPtr; Len: Integer; out Value: TDateTime; Timezone: PTimezone = nil);
  123. procedure xsdParseDateTime(Chars: xmlCharPtr; Len: Integer; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil);
  124. procedure xsdParseDateTime(Chars: xmlCharPtr; Len: Integer; out Value: TDateTime; Timezone: PTimezone = nil);
  125. procedure xsdParseDecimal(Chars: xmlCharPtr; Len: Integer; out Value: Extended);
  126. procedure xsdParseDouble(Chars: xmlCharPtr; Len: Integer; out Value: Double);
  127. procedure xsdParseFloat(Chars: xmlCharPtr; Len: Integer; out Value: Single);
  128. procedure xsdParseInteger(Chars: xmlCharPtr; Len: Integer; out Value: Int64);
  129. procedure xsdParseNonNegativeInteger(Chars: xmlCharPtr; Len: Integer; out Value: QWord);
  130. procedure xsdParseNonPositiveInteger(Chars: xmlCharPtr; Len: Integer; out Value: Int64);
  131. procedure xsdParseNegativeInteger(Chars: xmlCharPtr; Len: Integer; out Value: Int64);
  132. procedure xsdParsePositiveInteger(Chars: xmlCharPtr; Len: Integer; out Value: QWord);
  133. procedure xsdParseByte(Chars: xmlCharPtr; Len: Integer; out Value: Shortint);
  134. procedure xsdParseShort(Chars: xmlCharPtr; Len: Integer; out Value: Smallint);
  135. procedure xsdParseInt(Chars: xmlCharPtr; Len: Integer; out Value: Longint);
  136. procedure xsdParseLong(Chars: xmlCharPtr; Len: Integer; out Value: Int64);
  137. procedure xsdParseUnsignedByte(Chars: xmlCharPtr; Len: Integer; out Value: Byte);
  138. procedure xsdParseUnsignedShort(Chars: xmlCharPtr; Len: Integer; out Value: Word);
  139. procedure xsdParseUnsignedInt(Chars: xmlCharPtr; Len: Integer; out Value: Longword);
  140. procedure xsdParseUnsignedLong(Chars: xmlCharPtr; Len: Integer; out Value: QWord);
  141. procedure xsdParseEnum(Chars: xmlCharPtr; Len: Integer; enum: array of Utf8String; out Value: Integer);
  142. function xsdParseString(Chars: xmlCharPtr; Len: Integer): Utf8String;
  143. function xsdParseStringLower(Chars: xmlCharPtr; Len: Integer): Utf8String;
  144. function xsdParseBoolean(Chars: xmlCharPtr; Len: Integer): Boolean;
  145. function xsdParseDate(Chars: xmlCharPtr; Len: Integer; Timezone: PTimezone = nil): TDateTime;
  146. function xsdParseTime(Chars: xmlCharPtr; Len: Integer; Timezone: PTimezone = nil): TDateTime;
  147. function xsdParseDateTime(Chars: xmlCharPtr; Len: Integer; Timezone: PTimezone = nil): TDateTime;
  148. function xsdParseDecimal(Chars: xmlCharPtr; Len: Integer): Extended;
  149. function xsdParseDouble(Chars: xmlCharPtr; Len: Integer): Double;
  150. function xsdParseFloat(Chars: xmlCharPtr; Len: Integer): Single;
  151. function xsdParseInteger(Chars: xmlCharPtr; Len: Integer): Int64;
  152. function xsdParseNonNegativeInteger(Chars: xmlCharPtr; Len: Integer): QWord;
  153. function xsdParseNonPositiveInteger(Chars: xmlCharPtr; Len: Integer): Int64;
  154. function xsdParseNegativeInteger(Chars: xmlCharPtr; Len: Integer): Int64;
  155. function xsdParsePositiveInteger(Chars: xmlCharPtr; Len: Integer): QWord;
  156. function xsdParseByte(Chars: xmlCharPtr; Len: Integer): Shortint;
  157. function xsdParseShort(Chars: xmlCharPtr; Len: Integer): Smallint;
  158. function xsdParseInt(Chars: xmlCharPtr; Len: Integer): Longint;
  159. function xsdParseLong(Chars: xmlCharPtr; Len: Integer): Int64;
  160. function xsdParseUnsignedByte(Chars: xmlCharPtr; Len: Integer): Byte;
  161. function xsdParseUnsignedShort(Chars: xmlCharPtr; Len: Integer): Word;
  162. function xsdParseUnsignedInt(Chars: xmlCharPtr; Len: Integer): Longword;
  163. function xsdParseUnsignedLong(Chars: xmlCharPtr; Len: Integer): QWord;
  164. function xsdParseEnum(Chars: xmlCharPtr; Len: Integer; enum: array of Utf8String): Integer;
  165. { Node creation functions }
  166. function xsdNewChildString(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Utf8String): xmlNodePtr;
  167. function xsdNewChildBoolean(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Boolean; UseWords: Boolean = False): xmlNodePtr;
  168. function xsdNewChildDate(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day: Longword; BC: Boolean = False; Timezone: PTimezone = nil): xmlNodePtr;
  169. function xsdNewChildDate(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Date: TDateTime; Timezone: PTimezone = nil): xmlNodePtr;
  170. function xsdNewChildTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil): xmlNodePtr;
  171. function xsdNewChildTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Time: TDateTime; Timezone: PTimezone = nil): xmlNodePtr;
  172. function xsdNewChildDateTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; BC: Boolean = False; Timezone: PTimezone = nil): xmlNodePtr;
  173. function xsdNewChildDateTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; DateTime: TDateTime; Timezone: PTimezone = nil): xmlNodePtr;
  174. function xsdNewChildDecimal(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Extended; Precision: Integer = 4; Digits: Integer = 1): xmlNodePtr;
  175. function xsdNewChildDouble(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Double): xmlNodePtr;
  176. function xsdNewChildFloat(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Single): xmlNodePtr;
  177. function xsdNewChildByte(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Shortint): xmlNodePtr;
  178. function xsdNewChildShort(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Smallint): xmlNodePtr;
  179. function xsdNewChildInt(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longint): xmlNodePtr;
  180. function xsdNewChildLong(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Int64): xmlNodePtr;
  181. function xsdNewChildUnsignedByte(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Byte): xmlNodePtr;
  182. function xsdNewChildUnsignedShort(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Word): xmlNodePtr;
  183. function xsdNewChildUnsignedInt(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longword): xmlNodePtr;
  184. function xsdNewChildUnsignedLong(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: QWord): xmlNodePtr;
  185. function xsdNewChildEnum(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; enum: array of Utf8String; Value: Integer): xmlNodePtr;
  186. { Property creation functions }
  187. function xsdNewPropString(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Utf8String): xmlAttrPtr;
  188. function xsdNewPropBoolean(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Boolean; UseWords: Boolean = False): xmlAttrPtr;
  189. function xsdNewPropDate(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day: Longword; BC: Boolean = False; Timezone: PTimezone = nil): xmlAttrPtr;
  190. function xsdNewPropDate(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Date: TDateTime; Timezone: PTimezone = nil): xmlAttrPtr;
  191. function xsdNewPropTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil): xmlAttrPtr;
  192. function xsdNewPropTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Time: TDateTime; Timezone: PTimezone = nil): xmlAttrPtr;
  193. function xsdNewPropDateTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; BC: Boolean = False; Timezone: PTimezone = nil): xmlAttrPtr;
  194. function xsdNewPropDateTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; DateTime: TDateTime; Timezone: PTimezone = nil): xmlAttrPtr;
  195. function xsdNewPropDecimal(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Extended; Precision: Integer = 4; Digits: Integer = 1): xmlAttrPtr;
  196. function xsdNewPropDouble(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Double): xmlAttrPtr;
  197. function xsdNewPropFloat(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Single): xmlAttrPtr;
  198. function xsdNewPropByte(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Shortint): xmlAttrPtr;
  199. function xsdNewPropShort(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Smallint): xmlAttrPtr;
  200. function xsdNewPropInt(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longint): xmlAttrPtr;
  201. function xsdNewPropLong(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Int64): xmlAttrPtr;
  202. function xsdNewPropUnsignedByte(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Byte): xmlAttrPtr;
  203. function xsdNewPropUnsignedShort(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Word): xmlAttrPtr;
  204. function xsdNewPropUnsignedInt(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longword): xmlAttrPtr;
  205. function xsdNewPropUnsignedLong(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: QWord): xmlAttrPtr;
  206. function xsdNewPropEnum(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; enum: array of Utf8String; Value: Integer): xmlAttrPtr;
  207. { Query functions }
  208. const
  209. NS_IGNORE : xmlCharPtr = nil;
  210. NS_EXCLUDE : xmlCharPtr = pointer(-1);
  211. { Node query functions }
  212. function xsdTestNodeNs(node: xmlNodePtr; nameSpace: xmlCharPtr): Boolean;
  213. function xsdTestNode(node: xmlNodePtr; name, nameSpace: xmlCharPtr): Boolean;
  214. function xsdTryGetChild(node: xmlNodePtr; name, nameSpace: xmlCharPtr; Index: Integer = 0): xmlNodePtr;
  215. function xsdTryGetChild(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out child: xmlNodePtr; Index: Integer = 0): Boolean;
  216. function xsdTryGetChildChars(node: xmlNodePtr; name, nameSpace: xmlCharPtr; Index: Integer = 0): xmlCharPtr;
  217. function xsdTryGetChildString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Utf8String; Index: Integer = 0): Boolean;
  218. function xsdTryGetChildBoolean(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Boolean; Index: Integer = 0): Boolean;
  219. function xsdTryGetChildDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil; Index: Integer = 0): Boolean;
  220. function xsdTryGetChildDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil; Index: Integer = 0): Boolean;
  221. function xsdTryGetChildTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil; Index: Integer = 0): Boolean;
  222. function xsdTryGetChildTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil; Index: Integer = 0): Boolean;
  223. function xsdTryGetChildDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil; Index: Integer = 0): Boolean;
  224. function xsdTryGetChildDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil; Index: Integer = 0): Boolean;
  225. function xsdTryGetChildDecimal(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Extended; Index: Integer = 0): Boolean;
  226. function xsdTryGetChildDouble(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Double; Index: Integer = 0): Boolean;
  227. function xsdTryGetChildFloat(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Single; Index: Integer = 0): Boolean;
  228. function xsdTryGetChildByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Shortint; Index: Integer = 0): Boolean;
  229. function xsdTryGetChildShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Smallint; Index: Integer = 0): Boolean;
  230. function xsdTryGetChildInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longint; Index: Integer = 0): Boolean;
  231. function xsdTryGetChildLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Int64; Index: Integer = 0): Boolean;
  232. function xsdTryGetChildUnsignedByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Byte; Index: Integer = 0): Boolean;
  233. function xsdTryGetChildUnsignedShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Word; Index: Integer = 0): Boolean;
  234. function xsdTryGetChildUnsignedInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longword; Index: Integer = 0): Boolean;
  235. function xsdTryGetChildUnsignedLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: QWord; Index: Integer = 0): Boolean;
  236. function xsdTryGetChildEnum(node: xmlNodePtr; name, nameSpace: xmlCharPtr; enum: array of Utf8String; out Value: Integer; Index: Integer = 0): Boolean;
  237. function xsdGetChild(node: xmlNodePtr; name, nameSpace: xmlCharPtr; Index: Integer = 0): xmlNodePtr;
  238. function xsdGetChildChars(node: xmlNodePtr; name, nameSpace: xmlCharPtr; Index: Integer = 0): xmlCharPtr;
  239. procedure xsdGetChildString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Utf8String; Index: Integer = 0);
  240. procedure xsdGetChildBoolean(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Boolean; Index: Integer = 0);
  241. procedure xsdGetChildDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil; Index: Integer = 0);
  242. procedure xsdGetChildDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil; Index: Integer = 0);
  243. procedure xsdGetChildTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil; Index: Integer = 0);
  244. procedure xsdGetChildTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil; Index: Integer = 0);
  245. procedure xsdGetChildDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil; Index: Integer = 0);
  246. procedure xsdGetChildDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil; Index: Integer = 0);
  247. procedure xsdGetChildDecimal(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Extended; Index: Integer = 0);
  248. procedure xsdGetChildDouble(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Double; Index: Integer = 0);
  249. procedure xsdGetChildFloat(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Single; Index: Integer = 0);
  250. procedure xsdGetChildByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Shortint; Index: Integer = 0);
  251. procedure xsdGetChildShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Smallint; Index: Integer = 0);
  252. procedure xsdGetChildInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longint; Index: Integer = 0);
  253. procedure xsdGetChildLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Int64; Index: Integer = 0);
  254. procedure xsdGetChildUnsignedByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Byte; Index: Integer = 0);
  255. procedure xsdGetChildUnsignedShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Word; Index: Integer = 0);
  256. procedure xsdGetChildUnsignedInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longword; Index: Integer = 0);
  257. procedure xsdGetChildUnsignedLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: QWord; Index: Integer = 0);
  258. procedure xsdGetChildEnum(node: xmlNodePtr; name, nameSpace: xmlCharPtr; enum: array of Utf8String; out Value: Integer; Index: Integer = 0);
  259. { Node parsing functions }
  260. function xsdTryNext(var node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlNodePtr;
  261. function xsdTryNext(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out last: xmlNodePtr): Boolean;
  262. function xsdTryNextChars(var node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlCharPtr;
  263. function xsdTryNextString(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Utf8String): Boolean;
  264. function xsdTryNextBoolean(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Boolean): Boolean;
  265. function xsdTryNextDate(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil): Boolean;
  266. function xsdTryNextDate(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil): Boolean;
  267. function xsdTryNextTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil): Boolean;
  268. function xsdTryNextTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil): Boolean;
  269. function xsdTryNextDateTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil): Boolean;
  270. function xsdTryNextDateTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil): Boolean;
  271. function xsdTryNextDecimal(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Extended): Boolean;
  272. function xsdTryNextDouble(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Double): Boolean;
  273. function xsdTryNextFloat(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Single): Boolean;
  274. function xsdTryNextByte(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Shortint): Boolean;
  275. function xsdTryNextShort(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Smallint): Boolean;
  276. function xsdTryNextInt(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longint): Boolean;
  277. function xsdTryNextLong(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Int64): Boolean;
  278. function xsdTryNextUnsignedByte(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Byte): Boolean;
  279. function xsdTryNextUnsignedShort(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Word): Boolean;
  280. function xsdTryNextUnsignedInt(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longword): Boolean;
  281. function xsdTryNextUnsignedLong(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: QWord): Boolean;
  282. function xsdTryNextEnum(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; enum: array of Utf8String; out Value: Integer): Boolean;
  283. function xsdNext(var node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlNodePtr;
  284. function xsdNextChars(var node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlCharPtr;
  285. procedure xsdNextString(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Utf8String);
  286. procedure xsdNextBoolean(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Boolean);
  287. procedure xsdNextDate(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil);
  288. procedure xsdNextDate(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil);
  289. procedure xsdNextTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil);
  290. procedure xsdNextTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil);
  291. procedure xsdNextDateTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil);
  292. procedure xsdNextDateTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil);
  293. procedure xsdNextDecimal(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Extended);
  294. procedure xsdNextDouble(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Double);
  295. procedure xsdNextFloat(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Single);
  296. procedure xsdNextByte(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Shortint);
  297. procedure xsdNextShort(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Smallint);
  298. procedure xsdNextInt(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longint);
  299. procedure xsdNextLong(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Int64);
  300. procedure xsdNextUnsignedByte(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Byte);
  301. procedure xsdNextUnsignedShort(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Word);
  302. procedure xsdNextUnsignedInt(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longword);
  303. procedure xsdNextUnsignedLong(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: QWord);
  304. procedure xsdNextEnum(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; enum: array of Utf8String; out Value: Integer);
  305. { Property query functions }
  306. function xsdTestPropNs(attr: xmlAttrPtr; nameSpace: xmlCharPtr): Boolean;
  307. function xsdTestProp(attr: xmlAttrPtr; name, nameSpace: xmlCharPtr): Boolean;
  308. function xsdTryGetProp(node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlAttrPtr;
  309. function xsdTryGetPropChars(node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlCharPtr;
  310. function xsdTryGetPropString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Utf8String): Boolean;
  311. function xsdTryGetPropBoolean(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Boolean): Boolean;
  312. function xsdTryGetPropDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil): Boolean;
  313. function xsdTryGetPropDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil): Boolean;
  314. function xsdTryGetPropTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil): Boolean;
  315. function xsdTryGetPropTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil): Boolean;
  316. function xsdTryGetPropDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil): Boolean;
  317. function xsdTryGetPropDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil): Boolean;
  318. function xsdTryGetPropDecimal(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Extended): Boolean;
  319. function xsdTryGetPropDouble(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Double): Boolean;
  320. function xsdTryGetPropFloat(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Single): Boolean;
  321. function xsdTryGetPropByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Shortint): Boolean;
  322. function xsdTryGetPropShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Smallint): Boolean;
  323. function xsdTryGetPropInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longint): Boolean;
  324. function xsdTryGetPropLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Int64): Boolean;
  325. function xsdTryGetPropUnsignedByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Byte): Boolean;
  326. function xsdTryGetPropUnsignedShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Word): Boolean;
  327. function xsdTryGetPropUnsignedInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longword): Boolean;
  328. function xsdTryGetPropUnsignedLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: QWord): Boolean;
  329. function xsdTryGetPropEnum(node: xmlNodePtr; name, nameSpace: xmlCharPtr; enum: array of Utf8String; out Value: Integer): Boolean;
  330. function xsdGetProp(node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlAttrPtr;
  331. function xsdGetPropChars(node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlCharPtr;
  332. procedure xsdGetPropString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Utf8String);
  333. procedure xsdGetPropBoolean(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Boolean);
  334. procedure xsdGetPropDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil);
  335. procedure xsdGetPropDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil);
  336. procedure xsdGetPropTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil);
  337. procedure xsdGetPropTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil);
  338. procedure xsdGetPropDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone = nil; BC: PBoolean = nil);
  339. procedure xsdGetPropDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone = nil);
  340. procedure xsdGetPropDecimal(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Extended);
  341. procedure xsdGetPropDouble(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Double);
  342. procedure xsdGetPropFloat(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Single);
  343. procedure xsdGetPropByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Shortint);
  344. procedure xsdGetPropShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Smallint);
  345. procedure xsdGetPropInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longint);
  346. procedure xsdGetPropLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Int64);
  347. procedure xsdGetPropUnsignedByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Byte);
  348. procedure xsdGetPropUnsignedShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Word);
  349. procedure xsdGetPropUnsignedInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longword);
  350. procedure xsdGetPropUnsignedLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: QWord);
  351. procedure xsdGetPropEnum(node: xmlNodePtr; name, nameSpace: xmlCharPtr; enum: array of Utf8String; out Value: Integer);
  352. function xsdRemoveBlanks(content: xmlCharPtr; out cleaned: Utf8String): boolean;
  353. implementation
  354. constructor XSDException.CreateNode(const Msg: String; name, nameSpace: xmlCharPtr);
  355. var
  356. S: String;
  357. begin
  358. S := PChar(name);
  359. if Assigned(nameSpace) then
  360. S := PChar(nameSpace)+':'+S;
  361. inherited CreateFmt(Msg, [S]);
  362. end;
  363. function xsdFormatBoolean(Value: Boolean; UseWords: Boolean): Utf8String;
  364. begin
  365. if UseWords then
  366. if Value then
  367. Result := 'true'
  368. else
  369. Result := 'false'
  370. else
  371. if Value then
  372. Result := '1'
  373. else
  374. Result := '0';
  375. end;
  376. function xsdFormatDate(Year, Month, Day: Longword; BC: Boolean; Timezone: PTimezone): Utf8String;
  377. begin
  378. Result := Format('%4.4d-%2.2u-%2.2u', [Year, Month, Day]);
  379. if BC then
  380. Result := '-' + Result;
  381. if Assigned(Timezone) then
  382. case Timezone^.Kind of
  383. tzUTC:
  384. Result := Result + 'Z';
  385. tzUser:
  386. begin
  387. if Timezone^.Hour >= 0 then
  388. Result := Result + '+'
  389. else
  390. Result := Result + '-';
  391. Result := Result + Format('%2.2d:%2.2u', [Timezone^.Hour, Timezone^.Minute]);
  392. end;
  393. end;
  394. end;
  395. function xsdFormatDate(Value: TDateTime; Timezone: PTimezone): Utf8String;
  396. var
  397. Year, Month, Day: Word;
  398. begin
  399. DecodeDate(Value, Year, Month, Day);
  400. Result := xsdFormatDate(Year, Month, Day, False, Timezone);
  401. end;
  402. function xsdFormatTime(Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone): Utf8String;
  403. begin
  404. Result := Format('%2.2u:%2.2u:%2.2u', [Hour, Minute, Second]);
  405. if Milliseconds > 0 then
  406. Result := Result + '.' + IntToStr(Milliseconds);
  407. if Assigned(Timezone) then
  408. case Timezone^.Kind of
  409. tzUTC:
  410. Result := Result + 'Z';
  411. tzUser:
  412. begin
  413. if Timezone^.Hour >= 0 then
  414. Result := Result + '+'
  415. else
  416. Result := Result + '-';
  417. Result := Result + Format('%2.2d:%2.2u', [Timezone^.Hour, Timezone^.Minute]);
  418. end;
  419. end;
  420. end;
  421. function xsdFormatTime(Value: TDateTime; Timezone: PTimezone): Utf8String;
  422. var
  423. Hour, Minute, Second, Milliseconds: Word;
  424. begin
  425. DecodeTime(Value, Hour, Minute, Second, Milliseconds);
  426. Result := xsdFormatTime(Hour, Minute, Second, Milliseconds, Timezone);
  427. end;
  428. function xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; BC: Boolean; Timezone: PTimezone): Utf8String;
  429. begin
  430. Result := xsdFormatDate(Year, Month, Day, BC, nil) + 'T' + xsdFormatTime(Hour, Minute, Second, Milliseconds, Timezone);
  431. end;
  432. function xsdFormatDateTime(Value: TDateTime; Timezone: PTimezone): Utf8String;
  433. var
  434. Year, Month, Day, Hour, Minute, Second, Milliseconds: Word;
  435. begin
  436. DecodeDateTime(Value, Year, Month, Day, Hour, Minute, Second, Milliseconds);
  437. Result := xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds, False, Timezone);
  438. end;
  439. function xsdFormatDecimal(Value: Extended; Precision: Integer; Digits: Integer): Utf8String;
  440. begin
  441. Result := FloatToStrF(Value, ffFixed, Precision, Digits);
  442. end;
  443. function xsdFormatDouble(Value: Double): Utf8String;
  444. begin
  445. Result := FloatToStr(Value);
  446. end;
  447. function xsdFormatFloat(Value: Single): Utf8String;
  448. begin
  449. Result := FloatToStr(Value);
  450. end;
  451. function xsdFormatByte(Value: Shortint): Utf8String;
  452. begin
  453. Result := IntToStr(Value);
  454. end;
  455. function xsdFormatShort(Value: Smallint): Utf8String;
  456. begin
  457. Result := IntToStr(Value);
  458. end;
  459. function xsdFormatInt(Value: Integer): Utf8String;
  460. begin
  461. Result := IntToStr(Value);
  462. end;
  463. function xsdFormatLong(Value: Int64): Utf8String;
  464. begin
  465. Result := IntToStr(Value);
  466. end;
  467. function xsdFormatUnsignedByte(Value: Byte): Utf8String;
  468. begin
  469. Result := IntToStr(Value);
  470. end;
  471. function xsdFormatUnsignedShort(Value: Word): Utf8String;
  472. begin
  473. Result := IntToStr(Value);
  474. end;
  475. function xsdFormatUnsignedInt(Value: Longword): Utf8String;
  476. begin
  477. Result := IntToStr(Value);
  478. end;
  479. function xsdFormatUnsignedLong(Value: QWord): Utf8String;
  480. begin
  481. Result := IntToStr(Value);
  482. end;
  483. function xsdFormatEnum(enum: array of Utf8String; Value: Integer): Utf8String;
  484. begin
  485. Result := enum[Value];
  486. end;
  487. procedure xsdTimeConvertTo(var Hour, Minute, Second, Milliseconds: Longword; const Current, Target: TTimezone);
  488. begin
  489. {$warning not implemented}
  490. end;
  491. procedure xsdDateConvertTo(var Year, Month, Day: Longword; const Current, Target: TTimezone);
  492. begin
  493. {$warning not implemented}
  494. end;
  495. procedure xsdDateTimeConvertTo(var Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; const Current, Target: TTimezone);
  496. begin
  497. {$warning not implemented}
  498. end;
  499. function __parseNonNegativeInteger(var P: PChar; const L: PChar; out Value: QWord): Boolean;
  500. begin
  501. { expect integer }
  502. Value := 0;
  503. while (P < L) and (P^ in ['0'..'9']) do
  504. begin
  505. Value := 10*Value + Ord(P^) - Ord('0');
  506. Inc(P);
  507. end;
  508. Result := True;
  509. end;
  510. function __parseInteger(var P: PChar; const L: PChar; out Value: Int64): Boolean;
  511. var
  512. N: Boolean;
  513. begin
  514. { allow '-' }
  515. N := (P < L) and (P^ = '-');
  516. if N then
  517. Inc(P);
  518. { expect integer }
  519. Value := 0;
  520. while (P < L) and (P^ in ['0'..'9']) do
  521. begin
  522. Value := 10*Value + Ord(P^) - Ord('0');
  523. Inc(P);
  524. end;
  525. if N then
  526. Value := -Value;
  527. Result := True;
  528. end;
  529. function __parseFloat(var P: PChar; const L: PChar; out Value: Extended): Boolean;
  530. var
  531. N: Boolean;
  532. Exp: Int64;
  533. Int: QWord;
  534. begin
  535. { allow 'Nan' }
  536. if (P+2 < L) and ((P^ = 'N') or (P^ = 'n')) then
  537. begin
  538. Inc(P);
  539. if (P^ <> 'A') and (P^ <> 'a') then Exit(False);
  540. Inc(P);
  541. if (P^ <> 'N') and (P^ <> 'n') then Exit(False);
  542. Inc(P);
  543. Value := Nan;
  544. Result := True;
  545. Exit;
  546. end;
  547. { allow '-' }
  548. N := (P < L) and (P^ = '-');
  549. if N then
  550. Inc(P);
  551. { allow 'Inf' }
  552. if (P+2 < L) and ((P^ = 'I') or (P^ = 'i')) then
  553. begin
  554. Inc(P);
  555. if (P^ <> 'N') and (P^ <> 'n') then Exit(False);
  556. Inc(P);
  557. if (P^ <> 'F') and (P^ <> 'f') then Exit(False);
  558. Inc(P);
  559. if N then
  560. Value := NegInfinity
  561. else
  562. Value := Infinity;
  563. Result := True;
  564. Exit;
  565. end;
  566. { expect integer }
  567. Int := 0;
  568. while (P < L) and (P^ in ['0'..'9']) do
  569. begin
  570. Int := 10*Int + Ord(P^) - Ord('0');
  571. Inc(P);
  572. end;
  573. Value := Int;
  574. { allow '.' }
  575. if (P < L) and (P^ = '.') then
  576. begin
  577. Inc(P);
  578. { expect integer }
  579. Exp := 1;
  580. Int := 0;
  581. while (P < L) and (P^ in ['0'..'9']) do
  582. begin
  583. Int := 10*Int + Ord(P^) - Ord('0');
  584. Exp := 10*Exp;
  585. Inc(P);
  586. end;
  587. Value := Value + Int / Exp;
  588. end;
  589. { allow 'E' or 'e' }
  590. if (P < L) and ((P^ = 'E') or (P^ = 'e')) then
  591. begin
  592. Inc(P);
  593. { expect integer }
  594. if not __parseInteger(P, L, Exp) then
  595. Exit(False);
  596. while Exp > 0 do
  597. begin
  598. Value := Value * 10;
  599. Dec(Exp);
  600. end;
  601. while Exp < 0 do
  602. begin
  603. Value := Value * 0.1;
  604. Inc(Exp);
  605. end;
  606. end;
  607. if N then
  608. Value := -Value;
  609. Result := True;
  610. end;
  611. function __parseTimezone(var P: PChar; const L: PChar; out T: TTimezone): Boolean;
  612. var
  613. I: Integer;
  614. N: Boolean;
  615. begin
  616. { allow 'Z' }
  617. if (P < L) and (P^ = 'Z') then
  618. begin
  619. T.Kind := tzUTC;
  620. T.Hour := 0;
  621. T.Minute := 0;
  622. Inc(P);
  623. end else
  624. { allow '+' or '-' }
  625. if (P < L) and (P^ in ['+','-']) then
  626. begin
  627. N := P^ = '-';
  628. Inc(P);
  629. { expect 00..13 }
  630. T.Hour := 0; I := 2;
  631. while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
  632. begin
  633. T.Hour := 10*T.Hour + Ord(P^) - Ord('0');
  634. Dec(I); Inc(P);
  635. end;
  636. if T.Hour > 13 then
  637. Exit(False);
  638. if N then
  639. T.Hour := -T.Hour;
  640. { expect ':' }
  641. if (P >= L) or (P^ <> ':') then
  642. Exit(False);
  643. Inc(P);
  644. { expect 00..59 }
  645. T.Minute := 0; I := 2;
  646. while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
  647. begin
  648. T.Minute := 10*T.Minute + Ord(P^) - Ord('0');
  649. Dec(I); Inc(P);
  650. end;
  651. if T.Minute > 59 then
  652. Exit(False);
  653. end else
  654. { unknown }
  655. begin
  656. T.Kind := tzUnknown;
  657. T.Hour := 0;
  658. T.Minute := 0;
  659. end;
  660. Result := True;
  661. end;
  662. function __parseDate(var P: PChar; const L: PChar; out Year, Month, Day: Longword; BC: PBoolean): Boolean;
  663. var
  664. I: Integer;
  665. begin
  666. { allow '-' }
  667. if (P < L) and (P^ = '-') then
  668. begin
  669. if Assigned(BC) then
  670. BC^ := True
  671. else
  672. Exit(False);
  673. Inc(P);
  674. end else
  675. if Assigned(BC) then
  676. BC^ := False;
  677. { expect Integer }
  678. Year := 0;
  679. while (P < L) and (P^ in ['0'..'9']) do
  680. begin
  681. Year := 10*Year + Ord(P^) - Ord('0');
  682. Inc(P);
  683. end;
  684. { expect '-' }
  685. if (P >= L) or (P^ <> '-') then
  686. Exit(False);
  687. Inc(P);
  688. { expect 01..12 }
  689. Month := 0; I := 2;
  690. while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
  691. begin
  692. Month := 10*Month + Ord(P^) - Ord('0');
  693. Dec(I); Inc(P);
  694. end;
  695. if (Month < 1) or (Month > 12) then
  696. Exit(False);
  697. { expect '-' }
  698. if (P >= L) or (P^ <> '-') then
  699. Exit(False);
  700. Inc(P);
  701. { expect 01..31 }
  702. Day := 0; I := 2;
  703. while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
  704. begin
  705. Day := 10*Day + Ord(P^) - Ord('0');
  706. Dec(I); Inc(P);
  707. end;
  708. if (Day < 1) or (Day > 31) then
  709. Exit(False);
  710. Result := True;
  711. end;
  712. function __parseTime(var P: PChar; const L: PChar; out Hour, Minute, Second, Milliseconds: Longword): Boolean;
  713. var
  714. I: Integer;
  715. begin
  716. { expect 00..24 }
  717. Hour := 0; I := 2;
  718. while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
  719. begin
  720. Hour := 10*Hour + Ord(P^) - Ord('0');
  721. Inc(P); Dec(I);
  722. end;
  723. if Hour > 24 then
  724. Exit(False);
  725. { expect ':' }
  726. if (P >= L) or (P^ <> ':') then
  727. Exit(False);
  728. Inc(P);
  729. { expect 00..59 }
  730. Minute := 0; I := 2;
  731. while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
  732. begin
  733. Minute := 10*Minute + Ord(P^) - Ord('0');
  734. Dec(I); Inc(P);
  735. end;
  736. if (Minute > 59) or ((Hour = 24) and (Minute > 0)) then
  737. Exit(False);
  738. { expect ':' }
  739. if (P >= L) or (P^ <> ':') then
  740. Exit(False);
  741. Inc(P);
  742. { expect 00..59 }
  743. Second := 0; I := 2;
  744. while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
  745. begin
  746. Second := 10*Second + Ord(P^) - Ord('0');
  747. Dec(I); Inc(P);
  748. end;
  749. if (Second > 59) or ((Hour = 24) and (Second > 0)) then
  750. Exit(False);
  751. { allow '.' }
  752. if (P < L) and (P^ = '.') then
  753. begin
  754. Inc(P);
  755. { expect integer }
  756. Milliseconds := 0; I := 4;
  757. while (P < L) and (P^ in ['0'..'9']) and (I > 0) do
  758. begin
  759. Milliseconds := 10*Milliseconds + Ord(P^) - Ord('0');
  760. Dec(I); Inc(P);
  761. end;
  762. if (Milliseconds > 999) or ((Hour = 24) and (Milliseconds > 0)) then
  763. Exit(False);
  764. end else
  765. Milliseconds := 0;
  766. Result := True;
  767. end;
  768. function xsdTryParseString(Chars: xmlCharPtr; Len: Integer; out Value: Utf8String): Boolean;
  769. const
  770. AllocChars = 256;
  771. var
  772. P,L,D: PByte;
  773. begin
  774. if Assigned(Chars) then
  775. begin
  776. P := PByte(Chars);
  777. if Len >= 0 then
  778. begin
  779. L := P + Len;
  780. SetLength(Value, Len);
  781. D := @Value[1];
  782. while P < L do
  783. begin
  784. D^ := P^;
  785. Inc(D);
  786. Inc(P);
  787. end;
  788. end else begin
  789. SetLength(Value, AllocChars);
  790. D := @Value[1];
  791. L := D + AllocChars;
  792. while P^ <> 0 do
  793. begin
  794. if D = L then
  795. begin
  796. Len := Length(Value);
  797. SetLength(Value, Len+AllocChars);
  798. D := @Value[Len+1];
  799. L := D + AllocChars;
  800. end;
  801. D^ := P^;
  802. Inc(D);
  803. Inc(P);
  804. end;
  805. SetLength(Value, P-PByte(Chars));
  806. end;
  807. Result := True;
  808. end else
  809. Result := False;
  810. end;
  811. {begin
  812. if Assigned(Chars) then
  813. begin
  814. if Len >= 0 then
  815. begin
  816. SetLength(Value, Len);
  817. Move(Chars^, Value[1], Len);
  818. end else
  819. Value := PChar(Chars);
  820. Result := True;
  821. end else
  822. Result := False;
  823. end;}
  824. function xsdTryParseStringLower(Chars: xmlCharPtr; Len: Integer; out Value: Utf8String): Boolean;
  825. const
  826. AllocChars = 256;
  827. var
  828. P,L,D: PByte;
  829. C: Byte;
  830. begin
  831. if Assigned(Chars) then
  832. begin
  833. P := PByte(Chars);
  834. if Len >= 0 then
  835. begin
  836. L := P + Len;
  837. SetLength(Value, Len);
  838. D := @Value[1];
  839. while P < L do
  840. begin
  841. C := P^;
  842. if (C>=65) and (C<=90) then Inc(C, 32);
  843. D^ := C;
  844. Inc(D);
  845. Inc(P);
  846. end;
  847. end else begin
  848. SetLength(Value, AllocChars);
  849. D := @Value[1];
  850. L := D + AllocChars;
  851. while P^ <> 0 do
  852. begin
  853. C := P^;
  854. if (C>=65) and (C<=90) then Inc(C, 32);
  855. if D = L then
  856. begin
  857. Len := Length(Value);
  858. SetLength(Value, Len+AllocChars);
  859. D := @Value[Len+1];
  860. L := D + AllocChars;
  861. end;
  862. D^ := C;
  863. Inc(D);
  864. Inc(P);
  865. end;
  866. SetLength(Value, P-PByte(Chars));
  867. end;
  868. Result := True;
  869. end else
  870. Result := False;
  871. end;
  872. function __strpas(Chars: xmlCharPtr; Len: Integer): Utf8String;
  873. begin
  874. if not xsdTryParseString(Chars, Len, Result) then
  875. Result := '';
  876. end;
  877. function xsdTryParseBoolean(Chars: xmlCharPtr; Len: Integer; out Value: Boolean): Boolean;
  878. var
  879. P: PChar;
  880. Num: QWord;
  881. begin
  882. if not Assigned(Chars) then
  883. Exit(False);
  884. if Len < 0 then
  885. begin
  886. P := PChar(Chars);
  887. Len := 0;
  888. while (Len < 7) and (P^ <> #0) do
  889. begin
  890. Inc(Len);
  891. Inc(P);
  892. end;
  893. end;
  894. case Len of
  895. 1: Num := PByte(Chars)^;
  896. 4: Num := PLongword(Chars)^;
  897. 5: Num := PLongword(Chars)^ or (QWord(Chars[4]) shl 32);
  898. else Exit(False);
  899. end;
  900. case Num of
  901. $30,
  902. $65736C6166,$65736C6146,$65736C4166,$65736C4146,$65734C6166,$65734C6146,$65734C4166,$65734C4146,
  903. $65536C6166,$65536C6146,$65536C4166,$65536C4146,$65534C6166,$65534C6146,$65534C4166,$65534C4146,
  904. $45736C6166,$45736C6146,$45736C4166,$45736C4146,$45734C6166,$45734C6146,$45734C4166,$45734C4146,
  905. $45536C6166,$45536C6146,$45536C4166,$45536C4146,$45534C6166,$45534C6146,$45534C4166,$45534C4146:
  906. Value := False;
  907. $31,
  908. $65757274,$65757254,$65755274,$65755254,$65557274,$65557254,$65555274,$65555254,
  909. $45757274,$45757254,$45755274,$45755254,$45557274,$45557254,$45555274,$45555254:
  910. Value := True;
  911. else Exit(False);
  912. end;
  913. Result := True;
  914. end;
  915. function xsdTryParseDate(Chars: xmlCharPtr; Len: Integer; out Year, Month, Day: Longword; Timezone: PTimezone; BC: PBoolean): Boolean;
  916. var
  917. P: PChar;
  918. L: PChar;
  919. T: TTimezone;
  920. begin
  921. P := PChar(Chars);
  922. if Len >= 0 then
  923. begin
  924. L := P + Len;
  925. Result := Assigned(P) and
  926. __parseDate(P, L, Year, Month, Day, BC) and
  927. __parseTimezone(P, L, T) and (P = L)
  928. end else
  929. Result := Assigned(P) and
  930. __parseDate(P, IGNORE_LAST, Year, Month, Day, BC) and
  931. __parseTimezone(P, IGNORE_LAST, T) and (P^ = #0);
  932. { assign Timezone if requested }
  933. if Result and Assigned(Timezone) then
  934. begin
  935. if Timezone^.Convert then
  936. xsdDateConvertTo(Year, Month, Day, T, Timezone^)
  937. else
  938. Timezone^ := T;
  939. end;
  940. end;
  941. function xsdTryParseDate(Chars: xmlCharPtr; Len: Integer; out Value: TDateTime; Timezone: PTimezone): Boolean;
  942. var
  943. Year, Month, Day: Longword;
  944. begin
  945. if xsdTryParseDate(Chars, Len, Year, Month, Day, Timezone, nil) then
  946. Result := TryEncodeDate(Year, Month, Day, Value)
  947. else
  948. Result := False;
  949. end;
  950. function xsdTryParseTime(Chars: xmlCharPtr; Len: Integer; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone): Boolean;
  951. var
  952. P: PChar;
  953. L: PChar;
  954. T: TTimezone;
  955. begin
  956. P := PChar(Chars);
  957. if Len >= 0 then
  958. begin
  959. L := P + Len;
  960. Result := Assigned(P) and
  961. __parseTime(P, L, Hour, Minute, Second, Milliseconds) and
  962. __parseTimezone(P, L, T) and (P = L)
  963. end else
  964. Result := Assigned(P) and
  965. __parseTime(P, IGNORE_LAST, Hour, Minute, Second, Milliseconds) and
  966. __parseTimezone(P, IGNORE_LAST, T) and (P^ = #0);
  967. { assign Timezone if requested }
  968. if Result and Assigned(Timezone) then
  969. begin
  970. if Timezone^.Convert then
  971. xsdTimeConvertTo(Hour, Minute, Second, Milliseconds, T, Timezone^)
  972. else
  973. Timezone^ := T;
  974. end;
  975. end;
  976. function xsdTryParseTime(Chars: xmlCharPtr; Len: Integer; out Value: TDateTime; Timezone: PTimezone): Boolean;
  977. var
  978. Hour, Minute, Second, Milliseconds: Longword;
  979. begin
  980. if xsdTryParseTime(Chars, Len, Hour, Minute, Second, Milliseconds, Timezone) then
  981. Result := TryEncodeTime(Hour, Minute, Second, Milliseconds, Value)
  982. else
  983. Result := False;
  984. end;
  985. function xsdTryParseDateTime(Chars: xmlCharPtr; Len: Integer; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone; BC: PBoolean): Boolean;
  986. function __parseT(var P: PChar; const L: PChar): Boolean;
  987. begin
  988. Result := (P < L) and (P^ = 'T');
  989. if Result then Inc(P);
  990. end;
  991. var
  992. P: PChar;
  993. L: PChar;
  994. T: TTimezone;
  995. begin
  996. P := PChar(Chars);
  997. if Len >= 0 then
  998. begin
  999. L := P + Len;
  1000. Result := Assigned(P) and
  1001. __parseDate(P, L, Year, Month, Day, BC) and
  1002. __parseT(P, L) and
  1003. __parseTime(P, L, Hour, Minute, Second, Milliseconds) and
  1004. __parseTimezone(P, L, T) and (P = L)
  1005. end else
  1006. Result := Assigned(P) and
  1007. __parseDate(P, IGNORE_LAST, Year, Month, Day, BC) and
  1008. __parseT(P, IGNORE_LAST) and
  1009. __parseTime(P, IGNORE_LAST, Hour, Minute, Second, Milliseconds) and
  1010. __parseTimezone(P, IGNORE_LAST, T) and (P^ = #0);
  1011. { assign Timezone if requested }
  1012. if Result and Assigned(Timezone) then
  1013. begin
  1014. if Timezone^.Convert then
  1015. xsdDateTimeConvertTo(Year, Month, Day, Hour, Minute, Second, Milliseconds, T, Timezone^)
  1016. else
  1017. Timezone^ := T;
  1018. end;
  1019. end;
  1020. function xsdTryParseDateTime(Chars: xmlCharPtr; Len: Integer; out Value: TDateTime; Timezone: PTimezone): Boolean;
  1021. var
  1022. Year, Month, Day: Longword;
  1023. Hour, Minute, Second, Milliseconds: Longword;
  1024. begin
  1025. if xsdTryParseDateTime(Chars, Len, Year, Month, Day, Hour, Minute, Second, Milliseconds, Timezone) then
  1026. Result := TryEncodeDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds, Value)
  1027. else
  1028. Result := False;
  1029. end;
  1030. function xsdTryParseDecimal(Chars: xmlCharPtr; Len: Integer; out Value: Extended): Boolean;
  1031. var
  1032. P: PChar;
  1033. L: PChar;
  1034. begin
  1035. P := PChar(Chars);
  1036. if Len >= 0 then
  1037. begin
  1038. L := P + Len;
  1039. Result := Assigned(P) and __parseFloat(P, L, Value) and (P = L)
  1040. end else
  1041. Result := Assigned(P) and __parseFloat(P, IGNORE_LAST, Value) and (P^ = #0);
  1042. end;
  1043. function xsdTryParseDouble(Chars: xmlCharPtr; Len: Integer; out Value: Double): Boolean;
  1044. var
  1045. P: PChar;
  1046. L: PChar;
  1047. Tmp: Extended;
  1048. begin
  1049. P := PChar(Chars);
  1050. if Len >= 0 then
  1051. begin
  1052. L := P + Len;
  1053. Result := Assigned(P) and __parseFloat(P, L, Tmp) and (P = L)
  1054. end else
  1055. Result := Assigned(P) and __parseFloat(P, IGNORE_LAST, Tmp) and (P^ = #0);
  1056. Value := Tmp;
  1057. end;
  1058. function xsdTryParseFloat(Chars: xmlCharPtr; Len: Integer; out Value: Single): Boolean;
  1059. var
  1060. P: PChar;
  1061. L: PChar;
  1062. Tmp: Extended;
  1063. begin
  1064. P := PChar(Chars);
  1065. if Len >= 0 then
  1066. begin
  1067. L := P + Len;
  1068. Result := Assigned(P) and __parseFloat(P, L, Tmp) and (P = L)
  1069. end else
  1070. Result := Assigned(P) and __parseFloat(P, IGNORE_LAST, Tmp) and (P^ = #0);
  1071. Value := Tmp;
  1072. end;
  1073. function xsdTryParseInteger(Chars: xmlCharPtr; Len: Integer; out Value: Int64): Boolean;
  1074. var
  1075. P: PChar;
  1076. L: PChar;
  1077. begin
  1078. P := PChar(Chars);
  1079. if Len >= 0 then
  1080. begin
  1081. L := P + Len;
  1082. Result := Assigned(P) and __parseInteger(P, L, Value) and (P = L)
  1083. end else
  1084. Result := Assigned(P) and __parseInteger(P, IGNORE_LAST, Value) and (P^ = #0);
  1085. end;
  1086. function xsdTryParseNonNegativeInteger(Chars: xmlCharPtr; Len: Integer; out Value: QWord): Boolean;
  1087. var
  1088. P: PChar;
  1089. L: PChar;
  1090. begin
  1091. P := PChar(Chars);
  1092. if Len >= 0 then
  1093. begin
  1094. L := P + Len;
  1095. Result := Assigned(P) and __parseNonNegativeInteger(P, L, Value) and (P = L)
  1096. end else
  1097. Result := Assigned(P) and __parseNonNegativeInteger(P, IGNORE_LAST, Value) and (P^ = #0);
  1098. end;
  1099. function xsdTryParseNonPositiveInteger(Chars: xmlCharPtr; Len: Integer; out Value: Int64): Boolean;
  1100. begin
  1101. Result := xsdTryParseInteger(Chars, Len, Value) and (Value <= 0);
  1102. end;
  1103. function xsdTryParseNegativeInteger(Chars: xmlCharPtr; Len: Integer; out Value: Int64): Boolean;
  1104. begin
  1105. Result := xsdTryParseInteger(Chars, Len, Value) and (Value <= -1);
  1106. end;
  1107. function xsdTryParsePositiveInteger(Chars: xmlCharPtr; Len: Integer; out Value: QWord): Boolean;
  1108. begin
  1109. Result := xsdTryParseNonNegativeInteger(Chars, Len, Value) and (Value >= 1);
  1110. end;
  1111. function xsdTryParseByte(Chars: xmlCharPtr; Len: Integer; out Value: Shortint): Boolean;
  1112. var
  1113. Tmp: Int64;
  1114. begin
  1115. Result := xsdTryParseInteger(Chars, Len, Tmp) and (Tmp <= 128) and (Tmp >= -127);
  1116. Value := Tmp;
  1117. end;
  1118. function xsdTryParseShort(Chars: xmlCharPtr; Len: Integer; out Value: Smallint): Boolean;
  1119. var
  1120. Tmp: Int64;
  1121. begin
  1122. Result := xsdTryParseInteger(Chars, Len, Tmp) and (Tmp <= 32767) and (Tmp >= -32768);
  1123. Value := Tmp;
  1124. end;
  1125. function xsdTryParseInt(Chars: xmlCharPtr; Len: Integer; out Value: Longint): Boolean;
  1126. var
  1127. Tmp: Int64;
  1128. begin
  1129. Result := xsdTryParseInteger(Chars, Len, Tmp) and (Tmp <= 2147483647) and (Tmp >= -2147483648);
  1130. Value := Tmp;
  1131. end;
  1132. function xsdTryParseLong(Chars: xmlCharPtr; Len: Integer; out Value: Int64): Boolean;
  1133. begin
  1134. Result := xsdTryParseInteger(Chars, Len, Value);
  1135. end;
  1136. function xsdTryParseUnsignedByte(Chars: xmlCharPtr; Len: Integer; out Value: Byte): Boolean;
  1137. var
  1138. Tmp: QWord;
  1139. begin
  1140. Result := xsdTryParseNonNegativeInteger(Chars, Len, Tmp) and (Tmp <= 255);
  1141. Value := Tmp;
  1142. end;
  1143. function xsdTryParseUnsignedShort(Chars: xmlCharPtr; Len: Integer; out Value: Word): Boolean;
  1144. var
  1145. Tmp: QWord;
  1146. begin
  1147. Result := xsdTryParseNonNegativeInteger(Chars, Len, Tmp) and (Tmp <= 65535);
  1148. Value := Tmp;
  1149. end;
  1150. function xsdTryParseUnsignedInt(Chars: xmlCharPtr; Len: Integer; out Value: Longword): Boolean;
  1151. var
  1152. Tmp: QWord;
  1153. begin
  1154. Result := xsdTryParseNonNegativeInteger(Chars, Len, Tmp) and (Tmp <= 4294967295);
  1155. Value := Tmp;
  1156. end;
  1157. function xsdTryParseUnsignedLong(Chars: xmlCharPtr; Len: Integer; out Value: QWord): Boolean;
  1158. begin
  1159. Result := xsdTryParseNonNegativeInteger(Chars, Len, Value)
  1160. end;
  1161. function xsdTryParseEnum(Chars: xmlCharPtr; Len: Integer; enum: array of Utf8String; out Value: Integer): Boolean;
  1162. var
  1163. Temp: Utf8String;
  1164. I: Integer;
  1165. begin
  1166. Temp := '';
  1167. Result := xsdTryParseString(Chars, Len, Temp);
  1168. if Result then
  1169. begin
  1170. for I := 0 to High(enum) do
  1171. if Temp = enum[I] then
  1172. begin
  1173. Value := I;
  1174. Exit(True);
  1175. end;
  1176. Result := False;
  1177. end;
  1178. end;
  1179. function xsdParseStringDef(Chars: xmlCharPtr; Len: Integer; Default: Utf8String): Utf8String;
  1180. begin
  1181. if not xsdTryParseString(Chars, Len, Result) then
  1182. Result := Default;
  1183. end;
  1184. function xsdParseStringLowerDef(Chars: xmlCharPtr; Len: Integer; Default: Utf8String): Utf8String;
  1185. begin
  1186. if not xsdTryParseStringLower(Chars, Len, Result) then
  1187. Result := Default;
  1188. end;
  1189. function xsdParseBooleanDef(Chars: xmlCharPtr; Len: Integer; Default: Boolean): Boolean;
  1190. begin
  1191. if not xsdTryParseBoolean(Chars, Len, Result) then
  1192. Result := Default;
  1193. end;
  1194. function xsdParseDateDef(Chars: xmlCharPtr; Len: Integer; Default: TDateTime; Timezone: PTimezone): TDateTime;
  1195. begin
  1196. if not xsdTryParseDate(Chars, Len, Result, Timezone) then
  1197. Result := Default;
  1198. end;
  1199. function xsdParseTimeDef(Chars: xmlCharPtr; Len: Integer; Default: TDateTime; Timezone: PTimezone): TDateTime;
  1200. begin
  1201. if not xsdTryParseTime(Chars, Len, Result, Timezone) then
  1202. Result := Default;
  1203. end;
  1204. function xsdParseDateTimeDef(Chars: xmlCharPtr; Len: Integer; Default: TDateTime; Timezone: PTimezone): TDateTime;
  1205. begin
  1206. if not xsdTryParseDateTime(Chars, Len, Result, Timezone) then
  1207. Result := Default;
  1208. end;
  1209. function xsdParseDecimalDef(Chars: xmlCharPtr; Len: Integer; Default: Extended): Extended;
  1210. begin
  1211. if not xsdTryParseDecimal(Chars, Len, Result) then
  1212. Result := Default;
  1213. end;
  1214. function xsdParseDoubleDef(Chars: xmlCharPtr; Len: Integer; Default: Double): Double;
  1215. begin
  1216. if not xsdTryParseDouble(Chars, Len, Result) then
  1217. Result := Default;
  1218. end;
  1219. function xsdParseFloatDef(Chars: xmlCharPtr; Len: Integer; Default: Single): Single;
  1220. begin
  1221. if not xsdTryParseFloat(Chars, Len, Result) then
  1222. Result := Default;
  1223. end;
  1224. function xsdParseIntegerDef(Chars: xmlCharPtr; Len: Integer; Default: Int64): Int64;
  1225. begin
  1226. if not xsdTryParseInteger(Chars, Len, Result) then
  1227. Result := Default;
  1228. end;
  1229. function xsdParseNonNegativeIntegerDef(Chars: xmlCharPtr; Len: Integer; Default: QWord): QWord;
  1230. begin
  1231. if not xsdTryParseNonNegativeInteger(Chars, Len, Result) then
  1232. Result := Default;
  1233. end;
  1234. function xsdParseNonPositiveIntegerDef(Chars: xmlCharPtr; Len: Integer; Default: Int64): Int64;
  1235. begin
  1236. if not xsdTryParseNonPositiveInteger(Chars, Len, Result) then
  1237. Result := Default;
  1238. end;
  1239. function xsdParseNegativeIntegerDef(Chars: xmlCharPtr; Len: Integer; Default: Int64): Int64;
  1240. begin
  1241. if not xsdTryParseNegativeInteger(Chars, Len, Result) then
  1242. Result := Default;
  1243. end;
  1244. function xsdParsePositiveIntegerDef(Chars: xmlCharPtr; Len: Integer; Default: QWord): QWord;
  1245. begin
  1246. if not xsdTryParsePositiveInteger(Chars, Len, Result) then
  1247. Result := Default;
  1248. end;
  1249. function xsdParseByteDef(Chars: xmlCharPtr; Len: Integer; Default: Shortint): Shortint;
  1250. begin
  1251. if not xsdTryParseByte(Chars, Len, Result) then
  1252. Result := Default;
  1253. end;
  1254. function xsdParseShortDef(Chars: xmlCharPtr; Len: Integer; Default: Smallint): Smallint;
  1255. begin
  1256. if not xsdTryParseShort(Chars, Len, Result) then
  1257. Result := Default;
  1258. end;
  1259. function xsdParseIntDef(Chars: xmlCharPtr; Len: Integer; Default: Longint): Longint;
  1260. begin
  1261. if not xsdTryParseInt(Chars, Len, Result) then
  1262. Result := Default;
  1263. end;
  1264. function xsdParseLongDef(Chars: xmlCharPtr; Len: Integer; Default: Int64): Int64;
  1265. begin
  1266. if not xsdTryParseLong(Chars, Len, Result) then
  1267. Result := Default;
  1268. end;
  1269. function xsdParseUnsignedByteDef(Chars: xmlCharPtr; Len: Integer; Default: Byte): Byte;
  1270. begin
  1271. if not xsdTryParseUnsignedByte(Chars, Len, Result) then
  1272. Result := Default;
  1273. end;
  1274. function xsdParseUnsignedShortDef(Chars: xmlCharPtr; Len: Integer; Default: Word): Word;
  1275. begin
  1276. if not xsdTryParseUnsignedShort(Chars, Len, Result) then
  1277. Result := Default;
  1278. end;
  1279. function xsdParseUnsignedIntDef(Chars: xmlCharPtr; Len: Integer; Default: Longword): Longword;
  1280. begin
  1281. if not xsdTryParseUnsignedInt(Chars, Len, Result) then
  1282. Result := Default;
  1283. end;
  1284. function xsdParseUnsignedLongDef(Chars: xmlCharPtr; Len: Integer; Default: QWord): QWord;
  1285. begin
  1286. if not xsdTryParseUnsignedLong(Chars, Len, Result) then
  1287. Result := Default;
  1288. end;
  1289. function xsdParseEnumDef(Chars: xmlCharPtr; Len: Integer; enum: array of Utf8String; Default: Integer): Integer;
  1290. begin
  1291. if not xsdTryParseEnum(Chars, Len, enum, Result) then
  1292. Result := Default;
  1293. end;
  1294. procedure xsdParseString(Chars: xmlCharPtr; Len: Integer; out Value: Utf8String);
  1295. begin
  1296. if not xsdTryParseString(Chars, Len, Value) then
  1297. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:string']);
  1298. end;
  1299. procedure xsdParseStringLower(Chars: xmlCharPtr; Len: Integer; out Value: Utf8String);
  1300. begin
  1301. if not xsdTryParseStringLower(Chars, Len, Value) then
  1302. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:string']);
  1303. end;
  1304. procedure xsdParseBoolean(Chars: xmlCharPtr; Len: Integer; out Value: Boolean);
  1305. begin
  1306. if not xsdTryParseBoolean(Chars, Len, Value) then
  1307. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:boolean']);
  1308. end;
  1309. procedure xsdParseDate(Chars: xmlCharPtr; Len: Integer; out Year, Month, Day: Longword; Timezone: PTimezone; BC: PBoolean);
  1310. begin
  1311. if not xsdTryParseDate(Chars, Len, Year, Month, Day, Timezone, BC) then
  1312. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:date']);
  1313. end;
  1314. procedure xsdParseDate(Chars: xmlCharPtr; Len: Integer; out Value: TDateTime; Timezone: PTimezone);
  1315. begin
  1316. if not xsdTryParseDate(Chars, Len, Value, Timezone) then
  1317. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:date']);
  1318. end;
  1319. procedure xsdParseTime(Chars: xmlCharPtr; Len: Integer; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone);
  1320. begin
  1321. if not xsdTryParseTime(Chars, Len, Hour, Minute, Second, Milliseconds, Timezone) then
  1322. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:time']);
  1323. end;
  1324. procedure xsdParseTime(Chars: xmlCharPtr; Len: Integer; out Value: TDateTime; Timezone: PTimezone);
  1325. begin
  1326. if not xsdTryParseTime(Chars, Len, Value, Timezone) then
  1327. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:time']);
  1328. end;
  1329. procedure xsdParseDateTime(Chars: xmlCharPtr; Len: Integer; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone; BC: PBoolean);
  1330. begin
  1331. if not xsdTryParseDateTime(Chars, Len, Year, Month, Day, Hour, Minute, Second, Milliseconds, Timezone, BC) then
  1332. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:dateTime']);
  1333. end;
  1334. procedure xsdParseDateTime(Chars: xmlCharPtr; Len: Integer; out Value: TDateTime; Timezone: PTimezone);
  1335. begin
  1336. if not xsdTryParseDateTime(Chars, Len, Value, Timezone) then
  1337. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:dateTime']);
  1338. end;
  1339. procedure xsdParseDecimal(Chars: xmlCharPtr; Len: Integer; out Value: Extended);
  1340. begin
  1341. if not xsdTryParseDecimal(Chars, Len, Value) then
  1342. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:decimal']);
  1343. end;
  1344. procedure xsdParseDouble(Chars: xmlCharPtr; Len: Integer; out Value: Double);
  1345. begin
  1346. if not xsdTryParseDouble(Chars, Len, Value) then
  1347. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:double']);
  1348. end;
  1349. procedure xsdParseFloat(Chars: xmlCharPtr; Len: Integer; out Value: Single);
  1350. begin
  1351. if not xsdTryParseFloat(Chars, Len, Value) then
  1352. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:float']);
  1353. end;
  1354. procedure xsdParseInteger(Chars: xmlCharPtr; Len: Integer; out Value: Int64);
  1355. begin
  1356. if not xsdTryParseInteger(Chars, Len, Value) then
  1357. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:integer']);
  1358. end;
  1359. procedure xsdParseNonNegativeInteger(Chars: xmlCharPtr; Len: Integer; out Value: QWord);
  1360. begin
  1361. if not xsdTryParseNonNegativeInteger(Chars, Len, Value) then
  1362. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:nonNegativeInteger']);
  1363. end;
  1364. procedure xsdParseNonPositiveInteger(Chars: xmlCharPtr; Len: Integer; out Value: Int64);
  1365. begin
  1366. if not xsdTryParseNonPositiveInteger(Chars, Len, Value) then
  1367. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:nonPositiveInteger']);
  1368. end;
  1369. procedure xsdParseNegativeInteger(Chars: xmlCharPtr; Len: Integer; out Value: Int64);
  1370. begin
  1371. if not xsdTryParseNegativeInteger(Chars, Len, Value) then
  1372. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:negativeInteger']);
  1373. end;
  1374. procedure xsdParsePositiveInteger(Chars: xmlCharPtr; Len: Integer; out Value: QWord);
  1375. begin
  1376. if not xsdTryParsePositiveInteger(Chars, Len, Value) then
  1377. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:positiveInteger']);
  1378. end;
  1379. procedure xsdParseByte(Chars: xmlCharPtr; Len: Integer; out Value: Shortint);
  1380. begin
  1381. if not xsdTryParseByte(Chars, Len, Value) then
  1382. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:byte']);
  1383. end;
  1384. procedure xsdParseShort(Chars: xmlCharPtr; Len: Integer; out Value: Smallint);
  1385. begin
  1386. if not xsdTryParseShort(Chars, Len, Value) then
  1387. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:short']);
  1388. end;
  1389. procedure xsdParseInt(Chars: xmlCharPtr; Len: Integer; out Value: Longint);
  1390. begin
  1391. if not xsdTryParseInt(Chars, Len, Value) then
  1392. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:int']);
  1393. end;
  1394. procedure xsdParseLong(Chars: xmlCharPtr; Len: Integer; out Value: Int64);
  1395. begin
  1396. if not xsdTryParseLong(Chars, Len, Value) then
  1397. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:long']);
  1398. end;
  1399. procedure xsdParseUnsignedByte(Chars: xmlCharPtr; Len: Integer; out Value: Byte);
  1400. begin
  1401. if not xsdTryParseUnsignedByte(Chars, Len, Value) then
  1402. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:unsignedByte']);
  1403. end;
  1404. procedure xsdParseUnsignedShort(Chars: xmlCharPtr; Len: Integer; out Value: Word);
  1405. begin
  1406. if not xsdTryParseUnsignedShort(Chars, Len, Value) then
  1407. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:unsignedShort']);
  1408. end;
  1409. procedure xsdParseUnsignedInt(Chars: xmlCharPtr; Len: Integer; out Value: Longword);
  1410. begin
  1411. if not xsdTryParseUnsignedInt(Chars, Len, Value) then
  1412. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:unsignedInt']);
  1413. end;
  1414. procedure xsdParseUnsignedLong(Chars: xmlCharPtr; Len: Integer; out Value: QWord);
  1415. begin
  1416. if not xsdTryParseUnsignedLong(Chars, Len, Value) then
  1417. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:unsignedLong']);
  1418. end;
  1419. procedure xsdParseEnum(Chars: xmlCharPtr; Len: Integer; enum: array of Utf8String; out Value: Integer);
  1420. begin
  1421. if not xsdTryParseEnum(Chars, Len, enum, Value) then
  1422. raise XSDException.CreateFmt(ParserError, [__strpas(Chars,Len), 'xs:enum']);
  1423. end;
  1424. function xsdParseString(Chars: xmlCharPtr; Len: Integer): Utf8String;
  1425. begin
  1426. xsdParseString(Chars, Len, Result);
  1427. end;
  1428. function xsdParseStringLower(Chars: xmlCharPtr; Len: Integer): Utf8String;
  1429. begin
  1430. xsdParseStringLower(Chars, Len, Result);
  1431. end;
  1432. function xsdParseBoolean(Chars: xmlCharPtr; Len: Integer): Boolean;
  1433. begin
  1434. xsdParseBoolean(Chars, Len, Result);
  1435. end;
  1436. function xsdParseDate(Chars: xmlCharPtr; Len: Integer; Timezone: PTimezone): TDateTime;
  1437. begin
  1438. xsdParseDate(Chars, Len, Result, Timezone);
  1439. end;
  1440. function xsdParseTime(Chars: xmlCharPtr; Len: Integer; Timezone: PTimezone): TDateTime;
  1441. begin
  1442. xsdParseTime(Chars, Len, Result, Timezone);
  1443. end;
  1444. function xsdParseDateTime(Chars: xmlCharPtr; Len: Integer; Timezone: PTimezone): TDateTime;
  1445. begin
  1446. xsdParseDateTime(Chars, Len, Result, Timezone);
  1447. end;
  1448. function xsdParseDecimal(Chars: xmlCharPtr; Len: Integer): Extended;
  1449. begin
  1450. xsdParseDecimal(Chars, Len, Result);
  1451. end;
  1452. function xsdParseDouble(Chars: xmlCharPtr; Len: Integer): Double;
  1453. begin
  1454. xsdParseDouble(Chars, Len, Result);
  1455. end;
  1456. function xsdParseFloat(Chars: xmlCharPtr; Len: Integer): Single;
  1457. begin
  1458. xsdParseFloat(Chars, Len, Result);
  1459. end;
  1460. function xsdParseInteger(Chars: xmlCharPtr; Len: Integer): Int64;
  1461. begin
  1462. xsdParseInteger(Chars, Len, Result);
  1463. end;
  1464. function xsdParseNonNegativeInteger(Chars: xmlCharPtr; Len: Integer): QWord;
  1465. begin
  1466. xsdParseNonNegativeInteger(Chars, Len, Result);
  1467. end;
  1468. function xsdParseNonPositiveInteger(Chars: xmlCharPtr; Len: Integer): Int64;
  1469. begin
  1470. xsdParseNonPositiveInteger(Chars, Len, Result);
  1471. end;
  1472. function xsdParseNegativeInteger(Chars: xmlCharPtr; Len: Integer): Int64;
  1473. begin
  1474. xsdParseNegativeInteger(Chars, Len, Result);
  1475. end;
  1476. function xsdParsePositiveInteger(Chars: xmlCharPtr; Len: Integer): QWord;
  1477. begin
  1478. xsdParsePositiveInteger(Chars, Len, Result);
  1479. end;
  1480. function xsdParseByte(Chars: xmlCharPtr; Len: Integer): Shortint;
  1481. begin
  1482. xsdParseByte(Chars, Len, Result);
  1483. end;
  1484. function xsdParseShort(Chars: xmlCharPtr; Len: Integer): Smallint;
  1485. begin
  1486. xsdParseShort(Chars, Len, Result);
  1487. end;
  1488. function xsdParseInt(Chars: xmlCharPtr; Len: Integer): Longint;
  1489. begin
  1490. xsdParseInt(Chars, Len, Result);
  1491. end;
  1492. function xsdParseLong(Chars: xmlCharPtr; Len: Integer): Int64;
  1493. begin
  1494. xsdParseLong(Chars, Len, Result);
  1495. end;
  1496. function xsdParseUnsignedByte(Chars: xmlCharPtr; Len: Integer): Byte;
  1497. begin
  1498. xsdParseUnsignedByte(Chars, Len, Result);
  1499. end;
  1500. function xsdParseUnsignedShort(Chars: xmlCharPtr; Len: Integer): Word;
  1501. begin
  1502. xsdParseUnsignedShort(Chars, Len, Result);
  1503. end;
  1504. function xsdParseUnsignedInt(Chars: xmlCharPtr; Len: Integer): Longword;
  1505. begin
  1506. xsdParseUnsignedInt(Chars, Len, Result);
  1507. end;
  1508. function xsdParseUnsignedLong(Chars: xmlCharPtr; Len: Integer): QWord;
  1509. begin
  1510. xsdParseUnsignedLong(Chars, Len, Result);
  1511. end;
  1512. function xsdParseEnum(Chars: xmlCharPtr; Len: Integer; enum: array of Utf8String): Integer;
  1513. begin
  1514. xsdParseEnum(Chars, Len, enum, Result);
  1515. end;
  1516. function xsdNewChildString(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Utf8String): xmlNodePtr;
  1517. begin
  1518. Result := xmlNewChild(parent, ns, name, PChar(Value));
  1519. end;
  1520. function xsdNewChildBoolean(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Boolean; UseWords: Boolean): xmlNodePtr;
  1521. var
  1522. Tmp: Utf8String;
  1523. begin
  1524. Tmp := xsdFormatBoolean(Value, UseWords);
  1525. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1526. end;
  1527. function xsdNewChildTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone): xmlNodePtr;
  1528. var
  1529. Tmp: Utf8String;
  1530. begin
  1531. Tmp := xsdFormatTime(Hour, Minute, Second, Milliseconds, Timezone);
  1532. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1533. end;
  1534. function xsdNewChildTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Time: TDateTime; Timezone: PTimezone): xmlNodePtr;
  1535. var
  1536. Tmp: Utf8String;
  1537. begin
  1538. Tmp := xsdFormatTime(Time, Timezone);
  1539. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1540. end;
  1541. function xsdNewChildDate(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day: Longword; BC: Boolean; Timezone: PTimezone): xmlNodePtr;
  1542. var
  1543. Tmp: Utf8String;
  1544. begin
  1545. Tmp := xsdFormatDate(Year, Month, Day, BC, Timezone);
  1546. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1547. end;
  1548. function xsdNewChildDate(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Date: TDateTime; Timezone: PTimezone): xmlNodePtr;
  1549. var
  1550. Tmp: Utf8String;
  1551. begin
  1552. Tmp := xsdFormatDate(Date, Timezone);
  1553. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1554. end;
  1555. function xsdNewChildDateTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; BC: Boolean; Timezone: PTimezone): xmlNodePtr;
  1556. var
  1557. Tmp: Utf8String;
  1558. begin
  1559. Tmp := xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds, BC, Timezone);
  1560. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1561. end;
  1562. function xsdNewChildDateTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; DateTime: TDateTime; Timezone: PTimezone): xmlNodePtr;
  1563. var
  1564. Tmp: Utf8String;
  1565. begin
  1566. Tmp := xsdFormatDateTime(DateTime, Timezone);
  1567. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1568. end;
  1569. function xsdNewChildDecimal(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Extended; Precision: Integer; Digits: Integer): xmlNodePtr;
  1570. var
  1571. Tmp: Utf8String;
  1572. begin
  1573. Tmp := xsdFormatDecimal(Value, Precision, Digits);
  1574. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1575. end;
  1576. function xsdNewChildDouble(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Double): xmlNodePtr;
  1577. var
  1578. Tmp: Utf8String;
  1579. begin
  1580. Tmp := xsdFormatDouble(Value);
  1581. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1582. end;
  1583. function xsdNewChildFloat(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Single): xmlNodePtr;
  1584. var
  1585. Tmp: Utf8String;
  1586. begin
  1587. Tmp := xsdFormatFloat(Value);
  1588. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1589. end;
  1590. function xsdNewChildByte(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Shortint): xmlNodePtr;
  1591. var
  1592. Tmp: Utf8String;
  1593. begin
  1594. Tmp := xsdFormatByte(Value);
  1595. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1596. end;
  1597. function xsdNewChildShort(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Smallint): xmlNodePtr;
  1598. var
  1599. Tmp: Utf8String;
  1600. begin
  1601. Tmp := xsdFormatShort(Value);
  1602. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1603. end;
  1604. function xsdNewChildInt(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longint): xmlNodePtr;
  1605. var
  1606. Tmp: Utf8String;
  1607. begin
  1608. Tmp := xsdFormatInt(Value);
  1609. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1610. end;
  1611. function xsdNewChildLong(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Int64): xmlNodePtr;
  1612. var
  1613. Tmp: Utf8String;
  1614. begin
  1615. Tmp := xsdFormatLong(Value);
  1616. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1617. end;
  1618. function xsdNewChildUnsignedByte(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Byte): xmlNodePtr;
  1619. var
  1620. Tmp: Utf8String;
  1621. begin
  1622. Tmp := xsdFormatUnsignedByte(Value);
  1623. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1624. end;
  1625. function xsdNewChildUnsignedShort(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Word): xmlNodePtr;
  1626. var
  1627. Tmp: Utf8String;
  1628. begin
  1629. Tmp := xsdFormatUnsignedShort(Value);
  1630. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1631. end;
  1632. function xsdNewChildUnsignedInt(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longword): xmlNodePtr;
  1633. var
  1634. Tmp: Utf8String;
  1635. begin
  1636. Tmp := xsdFormatUnsignedInt(Value);
  1637. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1638. end;
  1639. function xsdNewChildUnsignedLong(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: QWord): xmlNodePtr;
  1640. var
  1641. Tmp: Utf8String;
  1642. begin
  1643. Tmp := xsdFormatUnsignedLong(Value);
  1644. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1645. end;
  1646. function xsdNewChildEnum(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; enum: array of Utf8String; Value: Integer): xmlNodePtr;
  1647. var
  1648. Tmp: Utf8String;
  1649. begin
  1650. Tmp := xsdFormatEnum(enum, Value);
  1651. Result := xmlNewChild(parent, ns, name, PChar(Tmp));
  1652. end;
  1653. function xsdNewPropString(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Utf8String): xmlAttrPtr;
  1654. begin
  1655. Result := xmlNewNsProp(node, ns, name, PChar(Value));
  1656. end;
  1657. function xsdNewPropBoolean(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Boolean; UseWords: Boolean): xmlAttrPtr;
  1658. var
  1659. Tmp: Utf8String;
  1660. begin
  1661. Tmp := xsdFormatBoolean(Value, UseWords);
  1662. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1663. end;
  1664. function xsdNewPropTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone): xmlAttrPtr;
  1665. var
  1666. Tmp: Utf8String;
  1667. begin
  1668. Tmp := xsdFormatTime(Hour, Minute, Second, Milliseconds, Timezone);
  1669. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1670. end;
  1671. function xsdNewPropTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Time: TDateTime; Timezone: PTimezone): xmlAttrPtr;
  1672. var
  1673. Tmp: Utf8String;
  1674. begin
  1675. Tmp := xsdFormatTime(Time, Timezone);
  1676. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1677. end;
  1678. function xsdNewPropDate(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day: Longword; BC: Boolean; Timezone: PTimezone): xmlAttrPtr;
  1679. var
  1680. Tmp: Utf8String;
  1681. begin
  1682. Tmp := xsdFormatDate(Year, Month, Day, BC, Timezone);
  1683. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1684. end;
  1685. function xsdNewPropDate(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Date: TDateTime; Timezone: PTimezone): xmlAttrPtr;
  1686. var
  1687. Tmp: Utf8String;
  1688. begin
  1689. Tmp := xsdFormatDate(Date, Timezone);
  1690. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1691. end;
  1692. function xsdNewPropDateTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; BC: Boolean; Timezone: PTimezone): xmlAttrPtr;
  1693. var
  1694. Tmp: Utf8String;
  1695. begin
  1696. Tmp := xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second, Milliseconds, BC, Timezone);
  1697. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1698. end;
  1699. function xsdNewPropDateTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; DateTime: TDateTime; Timezone: PTimezone): xmlAttrPtr;
  1700. var
  1701. Tmp: Utf8String;
  1702. begin
  1703. Tmp := xsdFormatDateTime(DateTime, Timezone);
  1704. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1705. end;
  1706. function xsdNewPropDecimal(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Extended; Precision: Integer; Digits: Integer): xmlAttrPtr;
  1707. var
  1708. Tmp: Utf8String;
  1709. begin
  1710. Tmp := xsdFormatDecimal(Value, Precision, Digits);
  1711. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1712. end;
  1713. function xsdNewPropDouble(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Double): xmlAttrPtr;
  1714. var
  1715. Tmp: Utf8String;
  1716. begin
  1717. Tmp := xsdFormatDouble(Value);
  1718. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1719. end;
  1720. function xsdNewPropFloat(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Single): xmlAttrPtr;
  1721. var
  1722. Tmp: Utf8String;
  1723. begin
  1724. Tmp := xsdFormatFloat(Value);
  1725. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1726. end;
  1727. function xsdNewPropByte(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Shortint): xmlAttrPtr;
  1728. var
  1729. Tmp: Utf8String;
  1730. begin
  1731. Tmp := xsdFormatByte(Value);
  1732. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1733. end;
  1734. function xsdNewPropShort(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Smallint): xmlAttrPtr;
  1735. var
  1736. Tmp: Utf8String;
  1737. begin
  1738. Tmp := xsdFormatShort(Value);
  1739. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1740. end;
  1741. function xsdNewPropInt(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longint): xmlAttrPtr;
  1742. var
  1743. Tmp: Utf8String;
  1744. begin
  1745. Tmp := xsdFormatInt(Value);
  1746. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1747. end;
  1748. function xsdNewPropLong(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Int64): xmlAttrPtr;
  1749. var
  1750. Tmp: Utf8String;
  1751. begin
  1752. Tmp := xsdFormatLong(Value);
  1753. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1754. end;
  1755. function xsdNewPropUnsignedByte(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Byte): xmlAttrPtr;
  1756. var
  1757. Tmp: Utf8String;
  1758. begin
  1759. Tmp := xsdFormatUnsignedByte(Value);
  1760. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1761. end;
  1762. function xsdNewPropUnsignedShort(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Word): xmlAttrPtr;
  1763. var
  1764. Tmp: Utf8String;
  1765. begin
  1766. Tmp := xsdFormatUnsignedShort(Value);
  1767. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1768. end;
  1769. function xsdNewPropUnsignedInt(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longword): xmlAttrPtr;
  1770. var
  1771. Tmp: Utf8String;
  1772. begin
  1773. Tmp := xsdFormatUnsignedInt(Value);
  1774. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1775. end;
  1776. function xsdNewPropUnsignedLong(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: QWord): xmlAttrPtr;
  1777. var
  1778. Tmp: Utf8String;
  1779. begin
  1780. Tmp := xsdFormatUnsignedLong(Value);
  1781. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1782. end;
  1783. function xsdNewPropEnum(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; enum: array of Utf8String; Value: Integer): xmlAttrPtr;
  1784. var
  1785. Tmp: Utf8String;
  1786. begin
  1787. Tmp := xsdFormatEnum(enum, Value);
  1788. Result := xmlNewNsProp(node, ns, name, PChar(Tmp));
  1789. end;
  1790. function xsdTestNodeNs(node: xmlNodePtr; nameSpace: xmlCharPtr): Boolean;
  1791. begin
  1792. Result :=
  1793. (nameSpace = NS_IGNORE) or
  1794. ((nameSpace = NS_EXCLUDE) and (node^.ns = nil)) or
  1795. ((nameSpace <> NS_EXCLUDE) and (nameSpace <> NS_IGNORE) and (node^.ns <> nil) and (xmlStrEqual(nameSpace, node^.ns^.href) <> 0));
  1796. end;
  1797. function xsdTestNode(node: xmlNodePtr; name, nameSpace: xmlCharPtr): Boolean;
  1798. begin
  1799. Result := (node <> nil) and (xmlStrEqual(name, node^.name) <> 0) and xsdTestNodeNs(node, nameSpace);
  1800. end;
  1801. function xsdTryGetChild(node: xmlNodePtr; name, nameSpace: xmlCharPtr; Index: integer): xmlNodePtr;
  1802. begin
  1803. if Assigned(node) and (Index >= 0) then
  1804. begin
  1805. Result := node^.children;
  1806. while Assigned(Result) do
  1807. begin
  1808. if xsdTestNode(Result, name, nameSpace) then
  1809. begin
  1810. if Index = 0 then
  1811. Exit;
  1812. Dec(Index);
  1813. end;
  1814. Result := Result^.next;
  1815. end;
  1816. end else
  1817. Result := nil;
  1818. end;
  1819. function xsdTryGetChild(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out child: xmlNodePtr; Index: Integer): Boolean;
  1820. begin
  1821. child := xsdTryGetChild(node, name, nameSpace, Index);
  1822. Result := Assigned(child);
  1823. end;
  1824. function xsdTryGetChildChars(node: xmlNodePtr; name, nameSpace: xmlCharPtr; Index: Integer): xmlCharPtr;
  1825. begin
  1826. Result := xmlNodeGetContent(xsdTryGetChild(node, name, nameSpace, Index));
  1827. end;
  1828. function xsdTryGetChildString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Utf8String; Index: Integer): Boolean;
  1829. begin
  1830. Result := xsdTryParseString(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value);
  1831. end;
  1832. function xsdTryGetChildBoolean(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Boolean; Index: Integer): Boolean;
  1833. begin
  1834. Result := xsdTryParseBoolean(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value);
  1835. end;
  1836. function xsdTryGetChildDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day: Longword; Timezone: PTimezone; BC: PBoolean; Index: Integer): Boolean;
  1837. begin
  1838. Result := xsdTryParseDate(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Year, Month, Day, Timezone, BC);
  1839. end;
  1840. function xsdTryGetChildDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone; Index: Integer): Boolean;
  1841. begin
  1842. Result := xsdTryParseDate(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value, Timezone);
  1843. end;
  1844. function xsdTryGetChildTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone; Index: Integer): Boolean;
  1845. begin
  1846. Result := xsdTryParseTime(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Hour, Minute, Second, Milliseconds, Timezone);
  1847. end;
  1848. function xsdTryGetChildTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone; Index: Integer): Boolean;
  1849. begin
  1850. Result := xsdTryParseTime(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value, Timezone);
  1851. end;
  1852. function xsdTryGetChildDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone; BC: PBoolean; Index: Integer): Boolean;
  1853. begin
  1854. Result := xsdTryParseDateTime(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Year, Month, Day, Hour, Minute, Second, Milliseconds, Timezone, BC);
  1855. end;
  1856. function xsdTryGetChildDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone; Index: Integer): Boolean;
  1857. begin
  1858. Result := xsdTryParseDateTime(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value, Timezone);
  1859. end;
  1860. function xsdTryGetChildDecimal(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Extended; Index: Integer): Boolean;
  1861. begin
  1862. Result := xsdTryParseDecimal(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value);
  1863. end;
  1864. function xsdTryGetChildDouble(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Double; Index: Integer): Boolean;
  1865. begin
  1866. Result := xsdTryParseDouble(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value);
  1867. end;
  1868. function xsdTryGetChildFloat(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Single; Index: Integer): Boolean;
  1869. begin
  1870. Result := xsdTryParseFloat(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value);
  1871. end;
  1872. function xsdTryGetChildByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Shortint; Index: Integer): Boolean;
  1873. begin
  1874. Result := xsdTryParseByte(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value);
  1875. end;
  1876. function xsdTryGetChildShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Smallint; Index: Integer): Boolean;
  1877. begin
  1878. Result := xsdTryParseShort(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value);
  1879. end;
  1880. function xsdTryGetChildInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longint; Index: Integer): Boolean;
  1881. begin
  1882. Result := xsdTryParseInt(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value);
  1883. end;
  1884. function xsdTryGetChildLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Int64; Index: Integer): Boolean;
  1885. begin
  1886. Result := xsdTryParseLong(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value);
  1887. end;
  1888. function xsdTryGetChildUnsignedByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Byte; Index: Integer): Boolean;
  1889. begin
  1890. Result := xsdTryParseUnsignedByte(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value);
  1891. end;
  1892. function xsdTryGetChildUnsignedShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Word; Index: Integer): Boolean;
  1893. begin
  1894. Result := xsdTryParseUnsignedShort(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value);
  1895. end;
  1896. function xsdTryGetChildUnsignedInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longword; Index: Integer): Boolean;
  1897. begin
  1898. Result := xsdTryParseUnsignedInt(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value);
  1899. end;
  1900. function xsdTryGetChildUnsignedLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: QWord; Index: Integer): Boolean;
  1901. begin
  1902. Result := xsdTryParseUnsignedLong(xsdTryGetChildChars(node, name, nameSpace, Index), -1, Value);
  1903. end;
  1904. function xsdTryGetChildEnum(node: xmlNodePtr; name, nameSpace: xmlCharPtr; enum: array of Utf8String; out Value: Integer; Index: Integer): Boolean;
  1905. begin
  1906. Result := xsdTryParseEnum(xsdTryGetChildChars(node, name, nameSpace, Index), -1, enum, Value);
  1907. end;
  1908. function xsdGetChild(node: xmlNodePtr; name, nameSpace: xmlCharPtr; Index: Integer): xmlNodePtr;
  1909. begin
  1910. Result := xsdTryGetChild(node, name, nameSpace, Index);
  1911. if not Assigned(Result) then
  1912. raise XSDException.CreateNode(ChildNotFound, name, nameSpace);
  1913. end;
  1914. function xsdGetChildChars(node: xmlNodePtr; name, nameSpace: xmlCharPtr; Index: Integer): xmlCharPtr;
  1915. begin
  1916. Result := xmlNodeGetContent(xsdGetChild(node, name, nameSpace, Index));
  1917. end;
  1918. procedure xsdGetChildString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Utf8String; Index: Integer);
  1919. begin
  1920. xsdParseString(xsdGetChildChars(node, name, nameSpace, Index), -1, Value);
  1921. end;
  1922. procedure xsdGetChildBoolean(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Boolean; Index: Integer);
  1923. begin
  1924. xsdParseBoolean(xsdGetChildChars(node, name, nameSpace, Index), -1, Value);
  1925. end;
  1926. procedure xsdGetChildDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day: Longword; Timezone: PTimezone; BC: PBoolean; Index: Integer);
  1927. begin
  1928. xsdParseDate(xsdGetChildChars(node, name, nameSpace, Index), -1, Year, Month, Day, Timezone, BC);
  1929. end;
  1930. procedure xsdGetChildDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone; Index: Integer);
  1931. begin
  1932. xsdParseDate(xsdGetChildChars(node, name, nameSpace, Index), -1, Value, Timezone);
  1933. end;
  1934. procedure xsdGetChildTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone; Index: Integer);
  1935. begin
  1936. xsdParseTime(xsdGetChildChars(node, name, nameSpace, Index), -1, Hour, Minute, Second, Milliseconds, Timezone);
  1937. end;
  1938. procedure xsdGetChildTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone; Index: Integer);
  1939. begin
  1940. xsdParseTime(xsdGetChildChars(node, name, nameSpace, Index), -1, Value, Timezone);
  1941. end;
  1942. procedure xsdGetChildDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone; BC: PBoolean; Index: Integer);
  1943. begin
  1944. xsdParseDateTime(xsdGetChildChars(node, name, nameSpace, Index), -1, Year, Month, Day, Hour, Minute, Second, Milliseconds, Timezone, BC);
  1945. end;
  1946. procedure xsdGetChildDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone; Index: Integer);
  1947. begin
  1948. xsdParseDateTime(xsdGetChildChars(node, name, nameSpace, Index), -1, Value, Timezone);
  1949. end;
  1950. procedure xsdGetChildDecimal(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Extended; Index: Integer);
  1951. begin
  1952. xsdParseDecimal(xsdGetChildChars(node, name, nameSpace, Index), -1, Value);
  1953. end;
  1954. procedure xsdGetChildDouble(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Double; Index: Integer);
  1955. begin
  1956. xsdParseDouble(xsdGetChildChars(node, name, nameSpace, Index), -1, Value);
  1957. end;
  1958. procedure xsdGetChildFloat(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Single; Index: Integer);
  1959. begin
  1960. xsdParseFloat(xsdGetChildChars(node, name, nameSpace, Index), -1, Value);
  1961. end;
  1962. procedure xsdGetChildByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Shortint; Index: Integer);
  1963. begin
  1964. xsdParseByte(xsdGetChildChars(node, name, nameSpace, Index), -1, Value);
  1965. end;
  1966. procedure xsdGetChildShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Smallint; Index: Integer);
  1967. begin
  1968. xsdParseShort(xsdGetChildChars(node, name, nameSpace, Index), -1, Value);
  1969. end;
  1970. procedure xsdGetChildInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longint; Index: Integer);
  1971. begin
  1972. xsdParseInt(xsdGetChildChars(node, name, nameSpace, Index), -1, Value);
  1973. end;
  1974. procedure xsdGetChildLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Int64; Index: Integer);
  1975. begin
  1976. xsdParseLong(xsdGetChildChars(node, name, nameSpace, Index), -1, Value);
  1977. end;
  1978. procedure xsdGetChildUnsignedByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Byte; Index: Integer);
  1979. begin
  1980. xsdParseUnsignedByte(xsdGetChildChars(node, name, nameSpace, Index), -1, Value);
  1981. end;
  1982. procedure xsdGetChildUnsignedShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Word; Index: Integer);
  1983. begin
  1984. xsdParseUnsignedShort(xsdGetChildChars(node, name, nameSpace, Index), -1, Value);
  1985. end;
  1986. procedure xsdGetChildUnsignedInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longword; Index: Integer);
  1987. begin
  1988. xsdParseUnsignedInt(xsdGetChildChars(node, name, nameSpace, Index), -1, Value);
  1989. end;
  1990. procedure xsdGetChildUnsignedLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: QWord; Index: Integer);
  1991. begin
  1992. xsdParseUnsignedLong(xsdGetChildChars(node, name, nameSpace, Index), -1, Value);
  1993. end;
  1994. procedure xsdGetChildEnum(node: xmlNodePtr; name, nameSpace: xmlCharPtr; enum: array of Utf8String; out Value: Integer; Index: Integer);
  1995. begin
  1996. xsdParseEnum(xsdGetChildChars(node, name, nameSpace, Index), -1, enum, Value);
  1997. end;
  1998. function xsdTryNext(var node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlNodePtr;
  1999. begin
  2000. while Assigned(node) and (node^._type = XML_TEXT_NODE) do
  2001. node := node^.next;
  2002. if xsdTestNode(node, name, nameSpace) then
  2003. begin
  2004. Result := node;
  2005. node := node^.next;
  2006. end else
  2007. Result := nil;
  2008. end;
  2009. function xsdTryNext(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out last: xmlNodePtr): Boolean;
  2010. begin
  2011. last := xsdTryNext(node, name, nameSpace);
  2012. Result := Assigned(last);
  2013. end;
  2014. function xsdTryNextChars(var node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlCharPtr;
  2015. begin
  2016. Result := xmlNodeGetContent(xsdTryNext(node, name, nameSpace));
  2017. end;
  2018. function xsdTryNextString(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Utf8String): Boolean;
  2019. begin
  2020. Result := xsdTryParseString(xsdTryNextChars(node, name, nameSpace), -1, Value);
  2021. end;
  2022. function xsdTryNextBoolean(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Boolean): Boolean;
  2023. begin
  2024. Result := xsdTryParseBoolean(xsdTryNextChars(node, name, nameSpace), -1, Value);
  2025. end;
  2026. function xsdTryNextDate(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day: Longword; Timezone: PTimezone; BC: PBoolean): Boolean;
  2027. begin
  2028. Result := xsdTryParseDate(xsdTryNextChars(node, name, nameSpace), -1, Year, Month, Day, Timezone, BC);
  2029. end;
  2030. function xsdTryNextDate(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone): Boolean;
  2031. begin
  2032. Result := xsdTryParseDate(xsdTryNextChars(node, name, nameSpace), -1, Value, Timezone);
  2033. end;
  2034. function xsdTryNextTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone): Boolean;
  2035. begin
  2036. Result := xsdTryParseTime(xsdTryNextChars(node, name, nameSpace), -1, Hour, Minute, Second, Milliseconds, Timezone);
  2037. end;
  2038. function xsdTryNextTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone): Boolean;
  2039. begin
  2040. Result := xsdTryParseTime(xsdTryNextChars(node, name, nameSpace), -1, Value, Timezone);
  2041. end;
  2042. function xsdTryNextDateTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone; BC: PBoolean): Boolean;
  2043. begin
  2044. Result := xsdTryParseDateTime(xsdTryNextChars(node, name, nameSpace), -1, Year, Month, Day, Hour, Minute, Second, Milliseconds, Timezone, BC);
  2045. end;
  2046. function xsdTryNextDateTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone): Boolean;
  2047. begin
  2048. Result := xsdTryParseDateTime(xsdTryNextChars(node, name, nameSpace), -1, Value, Timezone);
  2049. end;
  2050. function xsdTryNextDecimal(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Extended): Boolean;
  2051. begin
  2052. Result := xsdTryParseDecimal(xsdTryNextChars(node, name, nameSpace), -1, Value);
  2053. end;
  2054. function xsdTryNextDouble(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Double): Boolean;
  2055. begin
  2056. Result := xsdTryParseDouble(xsdTryNextChars(node, name, nameSpace), -1, Value);
  2057. end;
  2058. function xsdTryNextFloat(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Single): Boolean;
  2059. begin
  2060. Result := xsdTryParseFloat(xsdTryNextChars(node, name, nameSpace), -1, Value);
  2061. end;
  2062. function xsdTryNextByte(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Shortint): Boolean;
  2063. begin
  2064. Result := xsdTryParseByte(xsdTryNextChars(node, name, nameSpace), -1, Value);
  2065. end;
  2066. function xsdTryNextShort(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Smallint): Boolean;
  2067. begin
  2068. Result := xsdTryParseShort(xsdTryNextChars(node, name, nameSpace), -1, Value);
  2069. end;
  2070. function xsdTryNextInt(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longint): Boolean;
  2071. begin
  2072. Result := xsdTryParseInt(xsdTryNextChars(node, name, nameSpace), -1, Value);
  2073. end;
  2074. function xsdTryNextLong(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Int64): Boolean;
  2075. begin
  2076. Result := xsdTryParseLong(xsdTryNextChars(node, name, nameSpace), -1, Value);
  2077. end;
  2078. function xsdTryNextUnsignedByte(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Byte): Boolean;
  2079. begin
  2080. Result := xsdTryParseUnsignedByte(xsdTryNextChars(node, name, nameSpace), -1, Value);
  2081. end;
  2082. function xsdTryNextUnsignedShort(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Word): Boolean;
  2083. begin
  2084. Result := xsdTryParseUnsignedShort(xsdTryNextChars(node, name, nameSpace), -1, Value);
  2085. end;
  2086. function xsdTryNextUnsignedInt(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longword): Boolean;
  2087. begin
  2088. Result := xsdTryParseUnsignedInt(xsdTryNextChars(node, name, nameSpace), -1, Value);
  2089. end;
  2090. function xsdTryNextUnsignedLong(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: QWord): Boolean;
  2091. begin
  2092. Result := xsdTryParseUnsignedLong(xsdTryNextChars(node, name, nameSpace), -1, Value);
  2093. end;
  2094. function xsdTryNextEnum(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; enum: array of Utf8String; out Value: Integer): Boolean;
  2095. begin
  2096. Result := xsdTryParseEnum(xsdTryNextChars(node, name, nameSpace), -1, enum, Value);
  2097. end;
  2098. function xsdNext(var node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlNodePtr;
  2099. begin
  2100. Result := xsdTryNext(node, name, nameSpace);
  2101. if not Assigned(Result) then
  2102. raise XSDException.CreateNode(ChildNotFound, name, nameSpace);
  2103. end;
  2104. function xsdNextChars(var node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlCharPtr;
  2105. begin
  2106. Result := xmlNodeGetContent(xsdNext(node, name, nameSpace));
  2107. end;
  2108. procedure xsdNextString(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Utf8String);
  2109. begin
  2110. xsdParseString(xsdNextChars(node, name, nameSpace), -1, Value);
  2111. end;
  2112. procedure xsdNextBoolean(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Boolean);
  2113. begin
  2114. xsdParseBoolean(xsdNextChars(node, name, nameSpace), -1, Value);
  2115. end;
  2116. procedure xsdNextDate(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day: Longword; Timezone: PTimezone; BC: PBoolean);
  2117. begin
  2118. xsdParseDate(xsdNextChars(node, name, nameSpace), -1, Year, Month, Day, Timezone, BC);
  2119. end;
  2120. procedure xsdNextDate(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone);
  2121. begin
  2122. xsdParseDate(xsdNextChars(node, name, nameSpace), -1, Value, Timezone);
  2123. end;
  2124. procedure xsdNextTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone);
  2125. begin
  2126. xsdParseTime(xsdNextChars(node, name, nameSpace), -1, Hour, Minute, Second, Milliseconds, Timezone);
  2127. end;
  2128. procedure xsdNextTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone);
  2129. begin
  2130. xsdParseTime(xsdNextChars(node, name, nameSpace), -1, Value, Timezone);
  2131. end;
  2132. procedure xsdNextDateTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone; BC: PBoolean);
  2133. begin
  2134. xsdParseDateTime(xsdNextChars(node, name, nameSpace), -1, Year, Month, Day, Hour, Minute, Second, Milliseconds, Timezone, BC);
  2135. end;
  2136. procedure xsdNextDateTime(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone);
  2137. begin
  2138. xsdParseDateTime(xsdNextChars(node, name, nameSpace), -1, Value, Timezone);
  2139. end;
  2140. procedure xsdNextDecimal(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Extended);
  2141. begin
  2142. xsdParseDecimal(xsdNextChars(node, name, nameSpace), -1, Value);
  2143. end;
  2144. procedure xsdNextDouble(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Double);
  2145. begin
  2146. xsdParseDouble(xsdNextChars(node, name, nameSpace), -1, Value);
  2147. end;
  2148. procedure xsdNextFloat(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Single);
  2149. begin
  2150. xsdParseFloat(xsdNextChars(node, name, nameSpace), -1, Value);
  2151. end;
  2152. procedure xsdNextByte(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Shortint);
  2153. begin
  2154. xsdParseByte(xsdNextChars(node, name, nameSpace), -1, Value);
  2155. end;
  2156. procedure xsdNextShort(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Smallint);
  2157. begin
  2158. xsdParseShort(xsdNextChars(node, name, nameSpace), -1, Value);
  2159. end;
  2160. procedure xsdNextInt(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longint);
  2161. begin
  2162. xsdParseInt(xsdNextChars(node, name, nameSpace), -1, Value);
  2163. end;
  2164. procedure xsdNextLong(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Int64);
  2165. begin
  2166. xsdParseLong(xsdNextChars(node, name, nameSpace), -1, Value);
  2167. end;
  2168. procedure xsdNextUnsignedByte(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Byte);
  2169. begin
  2170. xsdParseUnsignedByte(xsdNextChars(node, name, nameSpace), -1, Value);
  2171. end;
  2172. procedure xsdNextUnsignedShort(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Word);
  2173. begin
  2174. xsdParseUnsignedShort(xsdNextChars(node, name, nameSpace), -1, Value);
  2175. end;
  2176. procedure xsdNextUnsignedInt(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longword);
  2177. begin
  2178. xsdParseUnsignedInt(xsdNextChars(node, name, nameSpace), -1, Value);
  2179. end;
  2180. procedure xsdNextUnsignedLong(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: QWord);
  2181. begin
  2182. xsdParseUnsignedLong(xsdNextChars(node, name, nameSpace), -1, Value);
  2183. end;
  2184. procedure xsdNextEnum(var node: xmlNodePtr; name, nameSpace: xmlCharPtr; enum: array of Utf8String; out Value: Integer);
  2185. begin
  2186. xsdParseEnum(xsdNextChars(node, name, nameSpace), -1, enum, Value);
  2187. end;
  2188. function xsdTestPropNs(attr: xmlAttrPtr; nameSpace: xmlCharPtr): Boolean;
  2189. begin
  2190. Result :=
  2191. (nameSpace = NS_IGNORE) or
  2192. ((nameSpace = NS_EXCLUDE) and (attr^.ns = nil)) or
  2193. ((nameSpace <> NS_EXCLUDE) and (nameSpace <> NS_IGNORE) and (attr^.ns <> nil) and (xmlStrEqual(nameSpace, attr^.ns^.href) <> 0))
  2194. end;
  2195. function xsdTestProp(attr: xmlAttrPtr; name, nameSpace: xmlCharPtr): Boolean;
  2196. begin
  2197. Result := (attr <> nil) and (xmlStrEqual(name, attr^.name) <> 0) and xsdTestPropNs(attr, nameSpace);
  2198. end;
  2199. function xsdTryGetProp(node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlAttrPtr;
  2200. begin
  2201. if Assigned(node) then
  2202. begin
  2203. Result := node^.properties;
  2204. while Assigned(Result) do
  2205. begin
  2206. if xsdTestProp(Result, name, nameSpace) then
  2207. Exit;
  2208. Result := Result^.next;
  2209. end;
  2210. end else
  2211. Result := nil;
  2212. end;
  2213. function xsdTryGetPropChars(node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlCharPtr;
  2214. var
  2215. Prop: xmlAttrPtr;
  2216. begin
  2217. Prop := xsdTryGetProp(node, name, nameSpace);
  2218. if Assigned(Prop) then
  2219. Result := xmlNodeGetContent(Prop^.children)
  2220. else
  2221. Result := nil;
  2222. end;
  2223. function xsdTryGetPropString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Utf8String): Boolean;
  2224. begin
  2225. Result := xsdTryParseString(xsdTryGetPropChars(node, name, nameSpace), -1, Value);
  2226. end;
  2227. function xsdTryGetPropBoolean(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Boolean): Boolean;
  2228. begin
  2229. Result := xsdTryParseBoolean(xsdTryGetPropChars(node, name, nameSpace), -1, Value);
  2230. end;
  2231. function xsdTryGetPropDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day: Longword; Timezone: PTimezone; BC: PBoolean): Boolean;
  2232. begin
  2233. Result := xsdTryParseDate(xsdTryGetPropChars(node, name, nameSpace), -1, Year, Month, Day, Timezone, BC);
  2234. end;
  2235. function xsdTryGetPropDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone): Boolean;
  2236. begin
  2237. Result := xsdTryParseDate(xsdTryGetPropChars(node, name, nameSpace), -1, Value, Timezone);
  2238. end;
  2239. function xsdTryGetPropTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone): Boolean;
  2240. begin
  2241. Result := xsdTryParseTime(xsdTryGetPropChars(node, name, nameSpace), -1, Hour, Minute, Second, Milliseconds, Timezone);
  2242. end;
  2243. function xsdTryGetPropTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone): Boolean;
  2244. begin
  2245. Result := xsdTryParseTime(xsdTryGetPropChars(node, name, nameSpace), -1, Value, Timezone);
  2246. end;
  2247. function xsdTryGetPropDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone; BC: PBoolean): Boolean;
  2248. begin
  2249. Result := xsdTryParseDateTime(xsdTryGetPropChars(node, name, nameSpace), -1, Year, Month, Day, Hour, Minute, Second, Milliseconds, Timezone, BC);
  2250. end;
  2251. function xsdTryGetPropDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone): Boolean;
  2252. begin
  2253. Result := xsdTryParseDateTime(xsdTryGetPropChars(node, name, nameSpace), -1, Value, Timezone);
  2254. end;
  2255. function xsdTryGetPropDecimal(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Extended): Boolean;
  2256. begin
  2257. Result := xsdTryParseDecimal(xsdTryGetPropChars(node, name, nameSpace), -1, Value);
  2258. end;
  2259. function xsdTryGetPropDouble(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Double): Boolean;
  2260. begin
  2261. Result := xsdTryParseDouble(xsdTryGetPropChars(node, name, nameSpace), -1, Value);
  2262. end;
  2263. function xsdTryGetPropFloat(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Single): Boolean;
  2264. begin
  2265. Result := xsdTryParseFloat(xsdTryGetPropChars(node, name, nameSpace), -1, Value);
  2266. end;
  2267. function xsdTryGetPropByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Shortint): Boolean;
  2268. begin
  2269. Result := xsdTryParseByte(xsdTryGetPropChars(node, name, nameSpace), -1, Value);
  2270. end;
  2271. function xsdTryGetPropShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Smallint): Boolean;
  2272. begin
  2273. Result := xsdTryParseShort(xsdTryGetPropChars(node, name, nameSpace), -1, Value);
  2274. end;
  2275. function xsdTryGetPropInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longint): Boolean;
  2276. begin
  2277. Result := xsdTryParseInt(xsdTryGetPropChars(node, name, nameSpace), -1, Value);
  2278. end;
  2279. function xsdTryGetPropLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Int64): Boolean;
  2280. begin
  2281. Result := xsdTryParseLong(xsdTryGetPropChars(node, name, nameSpace), -1, Value);
  2282. end;
  2283. function xsdTryGetPropUnsignedByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Byte): Boolean;
  2284. begin
  2285. Result := xsdTryParseUnsignedByte(xsdTryGetPropChars(node, name, nameSpace), -1, Value);
  2286. end;
  2287. function xsdTryGetPropUnsignedShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Word): Boolean;
  2288. begin
  2289. Result := xsdTryParseUnsignedShort(xsdTryGetPropChars(node, name, nameSpace), -1, Value);
  2290. end;
  2291. function xsdTryGetPropUnsignedInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longword): Boolean;
  2292. begin
  2293. Result := xsdTryParseUnsignedInt(xsdTryGetPropChars(node, name, nameSpace), -1, Value);
  2294. end;
  2295. function xsdTryGetPropUnsignedLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: QWord): Boolean;
  2296. begin
  2297. Result := xsdTryParseUnsignedLong(xsdTryGetPropChars(node, name, nameSpace), -1, Value);
  2298. end;
  2299. function xsdTryGetPropEnum(node: xmlNodePtr; name, nameSpace: xmlCharPtr; enum: array of Utf8String; out Value: Integer): Boolean;
  2300. begin
  2301. Result := xsdTryParseEnum(xsdTryGetPropChars(node, name, nameSpace), -1, enum, Value);
  2302. end;
  2303. function xsdGetProp(node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlAttrPtr;
  2304. begin
  2305. Result := xsdTryGetProp(node, name, nameSpace);
  2306. if not Assigned(Result) then
  2307. raise XSDException.CreateNode(PropNotFound, name, nameSpace);
  2308. end;
  2309. function xsdGetPropChars(node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlCharPtr;
  2310. begin
  2311. Result := xmlNodeGetContent(xsdGetProp(node, name, nameSpace)^.children);
  2312. end;
  2313. procedure xsdGetPropString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Utf8String);
  2314. begin
  2315. xsdParseString(xsdGetPropChars(node, name, nameSpace), -1, Value);
  2316. end;
  2317. procedure xsdGetPropBoolean(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Boolean);
  2318. begin
  2319. xsdParseBoolean(xsdGetPropChars(node, name, nameSpace), -1, Value);
  2320. end;
  2321. procedure xsdGetPropDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day: Longword; Timezone: PTimezone; BC: PBoolean);
  2322. begin
  2323. xsdParseDate(xsdGetPropChars(node, name, nameSpace), -1, Year, Month, Day, Timezone, BC);
  2324. end;
  2325. procedure xsdGetPropDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone);
  2326. begin
  2327. xsdParseDate(xsdGetPropChars(node, name, nameSpace), -1, Value, Timezone);
  2328. end;
  2329. procedure xsdGetPropTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone);
  2330. begin
  2331. xsdParseTime(xsdGetPropChars(node, name, nameSpace), -1, Hour, Minute, Second, Milliseconds, Timezone);
  2332. end;
  2333. procedure xsdGetPropTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone);
  2334. begin
  2335. xsdParseTime(xsdGetPropChars(node, name, nameSpace), -1, Value, Timezone);
  2336. end;
  2337. procedure xsdGetPropDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Year, Month, Day, Hour, Minute, Second, Milliseconds: Longword; Timezone: PTimezone; BC: PBoolean);
  2338. begin
  2339. xsdParseDateTime(xsdGetPropChars(node, name, nameSpace), -1, Year, Month, Day, Hour, Minute, Second, Milliseconds, Timezone, BC);
  2340. end;
  2341. procedure xsdGetPropDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: TDateTime; Timezone: PTimezone);
  2342. begin
  2343. xsdParseDateTime(xsdGetPropChars(node, name, nameSpace), -1, Value, Timezone);
  2344. end;
  2345. procedure xsdGetPropDecimal(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Extended);
  2346. begin
  2347. xsdParseDecimal(xsdGetPropChars(node, name, nameSpace), -1, Value);
  2348. end;
  2349. procedure xsdGetPropDouble(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Double);
  2350. begin
  2351. xsdParseDouble(xsdGetPropChars(node, name, nameSpace), -1, Value);
  2352. end;
  2353. procedure xsdGetPropFloat(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Single);
  2354. begin
  2355. xsdParseFloat(xsdGetPropChars(node, name, nameSpace), -1, Value);
  2356. end;
  2357. procedure xsdGetPropByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Shortint);
  2358. begin
  2359. xsdParseByte(xsdGetPropChars(node, name, nameSpace), -1, Value);
  2360. end;
  2361. procedure xsdGetPropShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Smallint);
  2362. begin
  2363. xsdParseShort(xsdGetPropChars(node, name, nameSpace), -1, Value);
  2364. end;
  2365. procedure xsdGetPropInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longint);
  2366. begin
  2367. xsdParseInt(xsdGetPropChars(node, name, nameSpace), -1, Value);
  2368. end;
  2369. procedure xsdGetPropLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Int64);
  2370. begin
  2371. xsdParseLong(xsdGetPropChars(node, name, nameSpace), -1, Value);
  2372. end;
  2373. procedure xsdGetPropUnsignedByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Byte);
  2374. begin
  2375. xsdParseUnsignedByte(xsdGetPropChars(node, name, nameSpace), -1, Value);
  2376. end;
  2377. procedure xsdGetPropUnsignedShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Word);
  2378. begin
  2379. xsdParseUnsignedShort(xsdGetPropChars(node, name, nameSpace), -1, Value);
  2380. end;
  2381. procedure xsdGetPropUnsignedInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: Longword);
  2382. begin
  2383. xsdParseUnsignedInt(xsdGetPropChars(node, name, nameSpace), -1, Value);
  2384. end;
  2385. procedure xsdGetPropUnsignedLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; out Value: QWord);
  2386. begin
  2387. xsdParseUnsignedLong(xsdGetPropChars(node, name, nameSpace), -1, Value);
  2388. end;
  2389. procedure xsdGetPropEnum(node: xmlNodePtr; name, nameSpace: xmlCharPtr; enum: array of Utf8String; out Value: Integer);
  2390. begin
  2391. xsdParseEnum(xsdGetPropChars(node, name, nameSpace), -1, enum, Value);
  2392. end;
  2393. function xsdRemoveBlanks(content: xmlCharPtr; out cleaned: Utf8String): boolean;
  2394. var
  2395. Space: Boolean;
  2396. len: Integer;
  2397. begin
  2398. cleaned := '';
  2399. if Assigned(content) then
  2400. begin
  2401. Space := True;
  2402. while content^ <> #0 do
  2403. begin
  2404. if xmlIsBlank(cuint(content^)) then
  2405. begin
  2406. if not Space then
  2407. cleaned := cleaned + ' ';
  2408. Space := True;
  2409. end else begin
  2410. cleaned := cleaned + content^;
  2411. Space := False;
  2412. end;
  2413. Inc(content);
  2414. end;
  2415. end;
  2416. len := Length(cleaned);
  2417. if len > 0 then
  2418. begin
  2419. if cleaned[len] = ' ' then
  2420. SetLength(cleaned, len-1);
  2421. Result := True;
  2422. end else
  2423. Result := False;
  2424. end;
  2425. end.