* added several new helper functions to libxml2 (xmlxsd.pas)

git-svn-id: trunk@11796 -
This commit is contained in:
ivost 2008-09-16 22:35:57 +00:00
parent 6b473862cf
commit cf3fc4bd77
3 changed files with 620 additions and 63 deletions

View File

@ -427,7 +427,7 @@ end;
function htmlElementAllowedHereDesc(parent: htmlElemDescPtr; elt: htmlElemDescPtr): cint; function htmlElementAllowedHereDesc(parent: htmlElemDescPtr; elt: htmlElemDescPtr): cint;
begin begin
Result := htmlElementAllowedHere(parent, elt^.name); Result := htmlElementAllowedHere(parent, BAD_CAST(elt^.name));
end; end;
function htmlRequiredAttrs(elt: htmlElemDescPtr): ppchar; function htmlRequiredAttrs(elt: htmlElemDescPtr): ppchar;

View File

@ -9,7 +9,7 @@
*) *)
{$IFDEF POINTER} {$IFDEF POINTER}
xmlCharPtr = pointer; xmlCharPtr = ^xmlChar;
xmlCharPtrPtr = ^xmlCharPtr; xmlCharPtrPtr = ^xmlCharPtr;
{$ENDIF} {$ENDIF}

View File

@ -7,13 +7,17 @@ interface
uses uses
libxml2, libxml2,
DateUtils,
SysUtils; SysUtils;
{ Format functions } { Format functions }
function xsdFormatBoolean(Value: Boolean): String; function xsdFormatBoolean(Value: Boolean): String;
function xsdFormatDate(Year, Month, Day: Longword): String; function xsdFormatDate(Year, Month, Day: Longword): String;
function xsdFormatTime(Daytime: Longword): String; function xsdFormatDate(Date: TDateTime): String;
function xsdFormatDateTime(Year, Month, Day, Daytime: Longword): String; function xsdFormatTime(Hour, Minute, Second: Longword): String;
function xsdFormatTime(Time: TDateTime): String;
function xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second: Longword): String;
function xsdFormatDateTime(DateTime: TDateTime): String;
function xsdFormatDecimal(Value: Extended; Precision: Integer = 4; Digits: Integer = 1): String; function xsdFormatDecimal(Value: Extended; Precision: Integer = 4; Digits: Integer = 1): String;
function xsdFormatDouble(Value: Double): String; function xsdFormatDouble(Value: Double): String;
function xsdFormatFloat(Value: Single): String; function xsdFormatFloat(Value: Single): String;
@ -27,10 +31,11 @@ function xsdFormatUnsignedInt(Value: Longword): String;
function xsdFormatUnsignedLong(Value: QWord): String; function xsdFormatUnsignedLong(Value: QWord): String;
{ Node creation functions } { Node creation functions }
function xsdNewChildString(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: String): xmlNodePtr;
function xsdNewChildBoolean(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Boolean): xmlNodePtr; function xsdNewChildBoolean(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Boolean): xmlNodePtr;
function xsdNewChildDate(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day: Longword): xmlNodePtr; function xsdNewChildDate(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day: Longword): xmlNodePtr;
function xsdNewChildTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Daytime: Longword): xmlNodePtr; function xsdNewChildTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Hour, Minute, Second: Longword): xmlNodePtr;
function xsdNewChildDateTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day, Daytime: Longword): xmlNodePtr; function xsdNewChildDateTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day, Hour, Minute, Second: Longword): xmlNodePtr;
function xsdNewChildDecimal(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Extended; Precision: Integer = 4; Digits: Integer = 1): xmlNodePtr; function xsdNewChildDecimal(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Extended; Precision: Integer = 4; Digits: Integer = 1): xmlNodePtr;
function xsdNewChildDouble(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Double): xmlNodePtr; function xsdNewChildDouble(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Double): xmlNodePtr;
function xsdNewChildFloat(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Single): xmlNodePtr; function xsdNewChildFloat(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Single): xmlNodePtr;
@ -44,10 +49,11 @@ function xsdNewChildUnsignedInt(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharP
function xsdNewChildUnsignedLong(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: QWord): xmlNodePtr; function xsdNewChildUnsignedLong(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: QWord): xmlNodePtr;
{ Property creation functions } { Property creation functions }
function xsdNewPropString(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: String): xmlAttrPtr;
function xsdNewPropBoolean(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Boolean): xmlAttrPtr; function xsdNewPropBoolean(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Boolean): xmlAttrPtr;
function xsdNewPropDate(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day: Longword): xmlAttrPtr; function xsdNewPropDate(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day: Longword): xmlAttrPtr;
function xsdNewPropTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Daytime: Longword): xmlAttrPtr; function xsdNewPropTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Hour, Minute, Second: Longword): xmlAttrPtr;
function xsdNewPropDateTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day, Daytime: Longword): xmlAttrPtr; function xsdNewPropDateTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day, Hour, Minute, Second: Longword): xmlAttrPtr;
function xsdNewPropDecimal(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Extended; Precision: Integer = 4; Digits: Integer = 1): xmlAttrPtr; function xsdNewPropDecimal(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Extended; Precision: Integer = 4; Digits: Integer = 1): xmlAttrPtr;
function xsdNewPropDouble(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Double): xmlAttrPtr; function xsdNewPropDouble(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Double): xmlAttrPtr;
function xsdNewPropFloat(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Single): xmlAttrPtr; function xsdNewPropFloat(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Single): xmlAttrPtr;
@ -60,6 +66,59 @@ function xsdNewPropUnsignedShort(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPt
function xsdNewPropUnsignedInt(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longword): xmlAttrPtr; function xsdNewPropUnsignedInt(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longword): xmlAttrPtr;
function xsdNewPropUnsignedLong(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: QWord): xmlAttrPtr; function xsdNewPropUnsignedLong(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: QWord): xmlAttrPtr;
{ Query functions }
const
NS_IGNORE : xmlCharPtr = nil;
NS_EXCLUDE : xmlCharPtr = pointer(-1);
{ Node query functions }
function xsdHasChild(node: xmlNodePtr; name: xmlCharPtr; index: Integer = 0): xmlNodePtr;
function xsdHasNsChild(node: xmlNodePtr; name, nameSpace: xmlCharPtr; index: Integer = 0): xmlNodePtr;
function xsdGetChild(node: xmlNodePtr; name: xmlCharPtr; index: Integer = 0): xmlCharPtr;
function xsdGetNsChild(node: xmlNodePtr; name, nameSpace: xmlCharPtr; index: Integer = 0): xmlCharPtr;
function xsdGetChildString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: String; index: Integer = 0): String;
function xsdGetChildBoolean(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Boolean; index: Integer = 0): Boolean;
function xsdGetChildDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: TDateTime; index: Integer = 0): TDateTime;
function xsdGetChildTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: TDateTime; index: Integer = 0): TDateTime;
function xsdGetChildDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: TDateTime; index: Integer = 0): TDateTime;
function xsdGetChildDecimal(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Extended; index: Integer = 0): Extended;
function xsdGetChildDouble(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Double; index: Integer = 0): Double;
function xsdGetChildFloat(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Single; index: Integer = 0): Single;
function xsdGetChildByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Shortint; index: Integer = 0): Shortint;
function xsdGetChildShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Smallint; index: Integer = 0): Smallint;
function xsdGetChildInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Longint; index: Integer = 0): Longint;
function xsdGetChildLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Int64; index: Integer = 0): Int64;
function xsdGetChildUnsignedByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Byte; index: Integer = 0): Byte;
function xsdGetChildUnsignedShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Word; index: Integer = 0): Word;
function xsdGetChildUnsignedInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Longword; index: Integer = 0): Longword;
function xsdGetChildUnsignedLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: QWord; index: Integer = 0): QWord;
function xsdGetChildEnumString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; Values: array of string; index: Integer = 0): Integer;
{ Property query functions }
function xsdHasProp(node: xmlNodePtr; name: xmlCharPtr): xmlAttrPtr;
function xsdHasNsProp(node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlAttrPtr;
function xsdGetProp(node: xmlNodePtr; name: xmlCharPtr): xmlCharPtr;
function xsdGetNsProp(node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlCharPtr;
function xsdGetPropString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: String): String;
function xsdGetPropBoolean(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Boolean): Boolean;
function xsdGetPropDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: TDateTime): TDateTime;
function xsdGetPropTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: TDateTime): TDateTime;
function xsdGetPropDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: TDateTime): TDateTime;
function xsdGetPropDecimal(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Extended): Extended;
function xsdGetPropDouble(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Double): Double;
function xsdGetPropFloat(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Single): Single;
function xsdGetPropByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Shortint): Shortint;
function xsdGetPropShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Smallint): Smallint;
function xsdGetPropInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Longint): Longint;
function xsdGetPropLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Int64): Int64;
function xsdGetPropUnsignedByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Byte): Byte;
function xsdGetPropUnsignedShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Word): Word;
function xsdGetPropUnsignedInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Longword): Longword;
function xsdGetPropUnsignedLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: QWord): QWord;
function xsdGetPropEnumString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; Values: array of string): Integer;
function xsdRemoveBlanks(content: xmlCharPtr; out cleaned: string): boolean;
implementation implementation
function xsdFormatBoolean(Value: Boolean): String; function xsdFormatBoolean(Value: Boolean): String;
@ -75,34 +134,40 @@ begin
Result := Format('%4.4d-%2.2d-%2.2dZ', [Year, Month, Day]); Result := Format('%4.4d-%2.2d-%2.2dZ', [Year, Month, Day]);
end; end;
function xsdFormatTime(Daytime: Longword): String; function xsdFormatDate(Date: TDateTime): String;
var var
Hour, Minute, Second: Longword; Year, Month, Day: Word;
begin begin
Daytime := Daytime div 1000; // ms to sec DecodeDate(Date, Year, Month, Day);
Second := Daytime mod 60; // extract sec Result := xsdFormatDate(Year, Month, Day);
Daytime := Daytime div 60; // sec to min end;
Minute := Daytime mod 60; // extract min
Daytime := Daytime div 60; // min to hour
Hour := Daytime mod 60; // extract hour
function xsdFormatTime(Hour, Minute, Second: Longword): String;
begin
Result := Format('%2.2d:%2.2d:%2.2dZ', [Hour, Minute, Second]); Result := Format('%2.2d:%2.2d:%2.2dZ', [Hour, Minute, Second]);
end; end;
function xsdFormatDateTime(Year, Month, Day, Daytime: Longword): String; function xsdFormatTime(Time: TDateTime): String;
var var
Hour, Minute, Second: Longword; Hour, Minute, Second, Millisecond: Word;
begin begin
Daytime := Daytime div 1000; // ms to sec DecodeTime(Time, Hour, Minute, Second, Millisecond);
Second := Daytime mod 60; // extract sec Result := xsdFormatTime(Hour, Minute, Second);
Daytime := Daytime div 60; // sec to min end;
Minute := Daytime mod 60; // extract min
Daytime := Daytime div 60; // min to hour
Hour := Daytime mod 60; // extract hour
function xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second: Longword): String;
begin
Result := Format('%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2dZ', [Year, Month, Day, Hour, Minute, Second]); Result := Format('%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2dZ', [Year, Month, Day, Hour, Minute, Second]);
end; end;
function xsdFormatDateTime(DateTime: TDateTime): String;
var
Year, Month, Day, Hour, Minute, Second, Millisecond: Word;
begin
DecodeDateTime(DateTime, Year, Month, Day, Hour, Minute, Second, Millisecond);
Result := xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second);
end;
function xsdFormatDecimal(Value: Extended; Precision: Integer; Digits: Integer): String; function xsdFormatDecimal(Value: Extended; Precision: Integer; Digits: Integer): String;
begin begin
Result := FloatToStrF(Value, ffFixed, Precision, Digits); Result := FloatToStrF(Value, ffFixed, Precision, Digits);
@ -158,20 +223,25 @@ begin
Result := IntToStr(Value); Result := IntToStr(Value);
end; end;
function xsdNewChildString(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: String): xmlNodePtr;
begin
Result := xmlNewChild(parent, ns, name, BAD_CAST(Value));
end;
function xsdNewChildBoolean(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Boolean): xmlNodePtr; function xsdNewChildBoolean(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Boolean): xmlNodePtr;
var var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatBoolean(Value); Tmp := xsdFormatBoolean(Value);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Daytime: Longword): xmlNodePtr; function xsdNewChildTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Hour, Minute, Second: Longword): xmlNodePtr;
var var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatTime(Daytime); Tmp := xsdFormatTime(Hour, Minute, Second);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildDate(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day: Longword): xmlNodePtr; function xsdNewChildDate(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day: Longword): xmlNodePtr;
@ -179,15 +249,15 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatDate(Year, Month, Day); Tmp := xsdFormatDate(Year, Month, Day);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildDateTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day, Daytime: Longword): xmlNodePtr; function xsdNewChildDateTime(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day, Hour, Minute, Second: Longword): xmlNodePtr;
var var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatDateTime(Year, Month, Day, Daytime); Tmp := xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildDecimal(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Extended; Precision: Integer; Digits: Integer): xmlNodePtr; function xsdNewChildDecimal(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Extended; Precision: Integer; Digits: Integer): xmlNodePtr;
@ -195,7 +265,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatDecimal(Value, Precision, Digits); Tmp := xsdFormatDecimal(Value, Precision, Digits);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildDouble(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Double): xmlNodePtr; function xsdNewChildDouble(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Double): xmlNodePtr;
@ -203,7 +273,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatDouble(Value); Tmp := xsdFormatDouble(Value);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildFloat(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Single): xmlNodePtr; function xsdNewChildFloat(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Single): xmlNodePtr;
@ -211,7 +281,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatFloat(Value); Tmp := xsdFormatFloat(Value);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildByte(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Shortint): xmlNodePtr; function xsdNewChildByte(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Shortint): xmlNodePtr;
@ -219,7 +289,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatByte(Value); Tmp := xsdFormatByte(Value);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildShort(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Smallint): xmlNodePtr; function xsdNewChildShort(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Smallint): xmlNodePtr;
@ -227,7 +297,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatShort(Value); Tmp := xsdFormatShort(Value);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildInt(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longint): xmlNodePtr; function xsdNewChildInt(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longint): xmlNodePtr;
@ -235,7 +305,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatInt(Value); Tmp := xsdFormatInt(Value);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildLong(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Int64): xmlNodePtr; function xsdNewChildLong(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Int64): xmlNodePtr;
@ -243,7 +313,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatLong(Value); Tmp := xsdFormatLong(Value);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildUnsignedByte(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Byte): xmlNodePtr; function xsdNewChildUnsignedByte(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Byte): xmlNodePtr;
@ -251,7 +321,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatUnsignedByte(Value); Tmp := xsdFormatUnsignedByte(Value);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildUnsignedShort(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Word): xmlNodePtr; function xsdNewChildUnsignedShort(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Word): xmlNodePtr;
@ -259,7 +329,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatUnsignedShort(Value); Tmp := xsdFormatUnsignedShort(Value);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildUnsignedInt(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longword): xmlNodePtr; function xsdNewChildUnsignedInt(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longword): xmlNodePtr;
@ -267,7 +337,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatUnsignedInt(Value); Tmp := xsdFormatUnsignedInt(Value);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewChildUnsignedLong(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: QWord): xmlNodePtr; function xsdNewChildUnsignedLong(parent: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: QWord): xmlNodePtr;
@ -275,25 +345,28 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatUnsignedLong(Value); Tmp := xsdFormatUnsignedLong(Value);
Result := xmlNewChild(parent, ns, name, PChar(Tmp)); Result := xmlNewChild(parent, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropString(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: String): xmlAttrPtr;
begin
Result := xmlNewNsProp(node, ns, name, BAD_CAST(Value));
end;
function xsdNewPropBoolean(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Boolean): xmlAttrPtr; function xsdNewPropBoolean(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Boolean): xmlAttrPtr;
var var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatBoolean(Value); Tmp := xsdFormatBoolean(Value);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Daytime: Longword): xmlAttrPtr; function xsdNewPropTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Hour, Minute, Second: Longword): xmlAttrPtr;
var var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatTime(Daytime); Tmp := xsdFormatTime(Hour, Minute, Second);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropDate(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day: Longword): xmlAttrPtr; function xsdNewPropDate(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day: Longword): xmlAttrPtr;
@ -301,15 +374,15 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatDate(Year, Month, Day); Tmp := xsdFormatDate(Year, Month, Day);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropDateTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day, Daytime: Longword): xmlAttrPtr; function xsdNewPropDateTime(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Year, Month, Day, Hour, Minute, Second: Longword): xmlAttrPtr;
var var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatDateTime(Year, Month, Day, Daytime); Tmp := xsdFormatDateTime(Year, Month, Day, Hour, Minute, Second);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropDecimal(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Extended; Precision: Integer; Digits: Integer): xmlAttrPtr; function xsdNewPropDecimal(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Extended; Precision: Integer; Digits: Integer): xmlAttrPtr;
@ -317,7 +390,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatDecimal(Value, Precision, Digits); Tmp := xsdFormatDecimal(Value, Precision, Digits);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropDouble(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Double): xmlAttrPtr; function xsdNewPropDouble(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Double): xmlAttrPtr;
@ -325,7 +398,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatDouble(Value); Tmp := xsdFormatDouble(Value);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropFloat(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Single): xmlAttrPtr; function xsdNewPropFloat(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Single): xmlAttrPtr;
@ -333,7 +406,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatFloat(Value); Tmp := xsdFormatFloat(Value);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropByte(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Shortint): xmlAttrPtr; function xsdNewPropByte(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Shortint): xmlAttrPtr;
@ -341,7 +414,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatByte(Value); Tmp := xsdFormatByte(Value);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropShort(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Smallint): xmlAttrPtr; function xsdNewPropShort(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Smallint): xmlAttrPtr;
@ -349,7 +422,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatShort(Value); Tmp := xsdFormatShort(Value);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropInt(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longint): xmlAttrPtr; function xsdNewPropInt(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longint): xmlAttrPtr;
@ -357,7 +430,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatInt(Value); Tmp := xsdFormatInt(Value);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropLong(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Int64): xmlAttrPtr; function xsdNewPropLong(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Int64): xmlAttrPtr;
@ -365,7 +438,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatLong(Value); Tmp := xsdFormatLong(Value);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropUnsignedByte(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Byte): xmlAttrPtr; function xsdNewPropUnsignedByte(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Byte): xmlAttrPtr;
@ -373,7 +446,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatUnsignedByte(Value); Tmp := xsdFormatUnsignedByte(Value);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropUnsignedShort(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Word): xmlAttrPtr; function xsdNewPropUnsignedShort(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Word): xmlAttrPtr;
@ -381,7 +454,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatUnsignedShort(Value); Tmp := xsdFormatUnsignedShort(Value);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropUnsignedInt(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longword): xmlAttrPtr; function xsdNewPropUnsignedInt(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: Longword): xmlAttrPtr;
@ -389,7 +462,7 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatUnsignedInt(Value); Tmp := xsdFormatUnsignedInt(Value);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end; end;
function xsdNewPropUnsignedLong(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: QWord): xmlAttrPtr; function xsdNewPropUnsignedLong(node: xmlNodePtr; ns: xmlNsPtr; name: xmlCharPtr; Value: QWord): xmlAttrPtr;
@ -397,7 +470,491 @@ var
Tmp: String; Tmp: String;
begin begin
Tmp := xsdFormatUnsignedLong(Value); Tmp := xsdFormatUnsignedLong(Value);
Result := xmlNewNsProp(node, ns, name, PChar(Tmp)); Result := xmlNewNsProp(node, ns, name, BAD_CAST(Tmp));
end;
function xsdHasChild(node: xmlNodePtr; name: xmlCharPtr; index: integer): xmlNodePtr;
begin
Result := xsdHasNsChild(node, name, nil, index);
end;
function xsdHasNsChild(node: xmlNodePtr; name, nameSpace: xmlCharPtr; index: integer): xmlNodePtr;
begin
if Assigned(node) and (Index >= 0) then
begin
node := node^.children;
while Assigned(node) do
begin
if (xmlStrEqual(name, node^.name) <> 0) and ((nameSpace = NS_IGNORE) or
((nameSpace = NS_EXCLUDE) and (node^.ns = nil)) or
((nameSpace <> NS_EXCLUDE) and (nameSpace <> NS_IGNORE) and (node^.ns <> nil) and (xmlStrEqual(nameSpace, node^.ns^.prefix) <> 0))) then
begin
if index = 0 then
begin
result := node;
Exit;
end;
Dec(Index);
end;
node := node^.next;
end;
end;
Result := nil;
end;
function xsdGetChild(node: xmlNodePtr; name: xmlCharPtr; index: Integer): xmlCharPtr;
begin
Result := xsdGetNsChild(node, name, nil, index);
end;
function xsdGetNsChild(node: xmlNodePtr; name, nameSpace: xmlCharPtr; index: Integer): xmlCharPtr;
var
child: xmlNodePtr;
begin
child := xsdHasNsChild(node, name, nameSpace, index);
if Assigned(child) then
result := xmlNodeGetContent(child)
else
result := nil;
end;
function xsdGetChildString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: String; index: Integer): String;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
if assigned(value) then
result := pchar(value)
else
result := defaultValue;
end;
function xsdGetChildBoolean(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Boolean; index: Integer): Boolean;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
if assigned(value) then
result := StrToBoolDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetChildDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: TDateTime; index: Integer): TDateTime;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
{if assigned(value) then
result := StrToBoolDef(pchar(value), defaultValue)
else}
result := defaultValue;
end;
function xsdGetChildTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: TDateTime; index: Integer): TDateTime;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
{if assigned(value) then
result := StrToBoolDef(pchar(value), defaultValue)
else}
result := defaultValue;
end;
function xsdGetChildDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: TDateTime; index: Integer): TDateTime;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
{if assigned(value) then
result := StrToBoolDef(pchar(value), defaultValue)
else}
result := defaultValue;
end;
function xsdGetChildDecimal(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Extended; index: Integer): Extended;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
if assigned(value) then
result := StrToFloatDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetChildDouble(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Double; index: Integer): Double;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
if assigned(value) then
result := StrToFloatDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetChildFloat(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Single; index: Integer): Single;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
if assigned(value) then
result := StrToFloatDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetChildByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Shortint; index: Integer): Shortint;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetChildShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Smallint; index: Integer): Smallint;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetChildInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Longint; index: Integer): Longint;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetChildLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Int64; index: Integer): Int64;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetChildUnsignedByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Byte; index: Integer): Byte;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetChildUnsignedShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Word; index: Integer): Word;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetChildUnsignedInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Longword; index: Integer): Longword;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetChildUnsignedLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: QWord; index: Integer): QWord;
var
value: xmlCharPtr;
begin
value := xsdGetNsChild(node, name, nameSpace, index);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function IndexOfString(const S: String; const List: array of String): Integer;
var
I: Integer;
begin
for I := 0 to Length(List) - 1 do
if List[I] = S then
Exit(I);
Result := -1;
end;
function xsdGetChildEnumString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; Values: array of string; index: Integer = 0): Integer;
begin
Result := IndexOfString(xsdGetChildString(node, name, nameSpace, Values[0], index), Values);
end;
function xsdHasProp(node: xmlNodePtr; name: xmlCharPtr): xmlAttrPtr;
begin
result := xsdHasNsProp(node, name, nil);
end;
function xsdHasNsProp(node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlAttrPtr;
begin
if nameSpace = NS_EXCLUDE then
begin
result := xmlHasProp(node, name);
if Assigned(result) and (result^.ns <> nil) then
result := nil;
end else
result := xmlHasNsProp(node, name, nameSpace);
end;
function xsdGetProp(node: xmlNodePtr; name: xmlCharPtr): xmlCharPtr;
begin
result := xmlGetProp(node, name);
end;
function xsdGetNsProp(node: xmlNodePtr; name, nameSpace: xmlCharPtr): xmlCharPtr;
begin
if nameSpace = NS_EXCLUDE then
result := xmlGetNoNsProp(node, name)
else
result := xmlGetNsProp(node, name, nameSpace);
end;
function xsdGetPropString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: String): String;
var
value: xmlCharPtr;
begin
value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := pchar(value)
else
result := defaultValue;
end;
function xsdGetPropBoolean(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Boolean): Boolean;
var
value: xmlCharPtr;
begin
value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToBoolDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetPropDate(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: TDateTime): TDateTime;
var
value: xmlCharPtr;
begin
{value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else}
result := defaultValue;
end;
function xsdGetPropTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: TDateTime): TDateTime;
var
value: xmlCharPtr;
begin
{value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else}
result := defaultValue;
end;
function xsdGetPropDateTime(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: TDateTime): TDateTime;
var
value: xmlCharPtr;
begin
{value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else}
result := defaultValue;
end;
function xsdGetPropDecimal(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Extended): Extended;
var
value: xmlCharPtr;
begin
value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToFloatDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetPropDouble(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Double): Double;
var
value: xmlCharPtr;
begin
value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToFloatDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetPropFloat(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Single): Single;
var
value: xmlCharPtr;
begin
value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToFloatDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetPropByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Shortint): Shortint;
var
value: xmlCharPtr;
begin
value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetPropShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Smallint): Smallint;
var
value: xmlCharPtr;
begin
value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetPropInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Longint): Longint;
var
value: xmlCharPtr;
begin
value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetPropLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Int64): Int64;
var
value: xmlCharPtr;
begin
value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetPropUnsignedByte(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Byte): Byte;
var
value: xmlCharPtr;
begin
value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetPropUnsignedShort(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Word): Word;
var
value: xmlCharPtr;
begin
value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetPropUnsignedInt(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: Longword): Longword;
var
value: xmlCharPtr;
begin
value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetPropUnsignedLong(node: xmlNodePtr; name, nameSpace: xmlCharPtr; defaultValue: QWord): QWord;
var
value: xmlCharPtr;
begin
value := xsdGetNsProp(node, name, nameSpace);
if assigned(value) then
result := StrToIntDef(pchar(value), defaultValue)
else
result := defaultValue;
end;
function xsdGetPropEnumString(node: xmlNodePtr; name, nameSpace: xmlCharPtr; Values: array of string): Integer;
begin
result := IndexOfString(xsdGetPropString(node, name, nameSpace, Values[0]), Values);
end;
function xsdRemoveBlanks(content: xmlCharPtr; out cleaned: string): boolean;
var
Space: Boolean;
len: Integer;
begin
cleaned := '';
if Assigned(content) then
begin
Space := True;
while content^ <> 0 do
begin
if xmlIsBlank(content^) then
begin
if not Space then
cleaned := cleaned + ' ';
Space := True;
end else begin
cleaned := cleaned + chr(content^);
Space := False;
end;
Inc(content);
end;
end;
len := Length(cleaned);
if len > 0 then
begin
if cleaned[len] = ' ' then
SetLength(cleaned, len-1);
Result := True;
end else
Result := False;
end; end;
end. end.