Componentes.Terceros.RemObj.../internal/5.0.23.613/1/RemObjects SDK for Delphi/Source/uROXMLIntf.pas
david 2824855ea7 - Modificación del paquete RemObjects_Core_D10 para que sea un paquete de runtime/designtime (antes era designtime sólo)
- Recompilación en Delphi10 de todos los paquetes de RO para generar las DCU's en Lib\D10
- Recompilación en Delphi10 de todos los paquetes de DA para generar las DCU's en Lib\D10

git-svn-id: https://192.168.0.254/svn/Componentes.Terceros.RemObjects@9 b6239004-a887-0f4b-9937-50029ccdca16
2007-09-10 14:06:19 +00:00

168 lines
6.0 KiB
ObjectPascal

unit uROXMLIntf;
{----------------------------------------------------------------------------}
{ RemObjects SDK Library - Core Library }
{ }
{ compiler: Delphi 5 and up, Kylix 2 and up }
{ platform: Win32, Linux }
{ }
{ (c)opyright RemObjects Software. all rights reserved. }
{ }
{ Using this code requires a valid license of the RemObjects SDK }
{ which can be obtained at http://www.remobjects.com. }
{----------------------------------------------------------------------------}
{$I RemObjects.inc}
interface
uses Classes;
type
{ Misc. }
TXMLEncoding = (xeUTF8, xeUTF16); // Some are missing...
const
XMLEncodingStr : array[TXMLEncoding] of string = ('UTF8', 'UTF16');
XMLBooleans: array[boolean] of string = ('false', 'true');
type
{ Forward declarations }
IXMLNodeList = interface;
IXMLDocument = interface;
{ IXMLNode }
IXMLNode = interface
['{8E0508D5-EFC0-4E1F-9BC5-2CBE3536D008}']
function GetName : widestring;
function GetLocalName : widestring;
function GetRef : pointer;
function GetParent : IXMLNode;
function GetValue : Variant;
procedure SetValue(const Value : Variant);
function GetXML : widestring;
function GetAttributes(Index : integer) : IXMLNode;
function GetAttributeCount : integer;
function GetChildren(Index : integer) : IXMLNode;
function GetChildrenCount : integer;
function Add(const aNodeName : widestring; aNameSpaceURI: widestring = '') : IXMLNode;
function AddXml(const Xml: widestring): IXMLNode;
function AddAttribute(const anAttributeName : widestring; const anAttributeValue : Variant) : IXMLNode;
procedure Delete(Index : integer);
procedure Remove(const aNode : IXMLNode);
function GetNodeByName(const aNodeName : widestring) : IXMLNode; // Returns NIL if none is found or exception. Up to you.
function GetNodeValue(const aNodeName : widestring; const Default : Variant) : Variant;
function GetAttributeByName(const anAttributeName : widestring) : IXMLNode;
function GetAttributeValue(const anAttributeName : widestring; DefaultValue : Variant) : Variant;
function GetNodesByName(const aNodeName : widestring) : IXMLNodeList; // Returns NIL if none are found or exception. Up to you.
function GetNodeByAttribute(const anAttributeName, anAttributeValue : widestring) : IXMLNode; // Returns NIL if none are found or exception. Up to you.
function GetFirstChild: IXMLNode;
function GetNextSibling: IXMLNode;
function GetNamespaceURI: widestring;
function GetDocument: IXMLDocument;
property Name : widestring read GetName; // When one is creates it MUST have a name
property LocalName : widestring read GetLocalName;
property NamespaceURI : widestring read GetNamespaceURI;
property Value : Variant read GetValue write SetValue; // Only possible if there are no children.
property Attributes[Index : integer] : IXMLNode read GetAttributes; // NIL if it has no attributes. I am open to other solutions
property AttributeCount : integer read GetAttributeCount;
property Children[Index : integer] : IXMLNode read GetChildren; // NIL if it has no children. I am open to other solutions
property ChildrenCount : integer read GetChildrenCount;
property FirstChild: IXMLNode read GetFirstChild;
property NextSibling: IXMLNode read GetNextSibling;
property XML : widestring read GetXML;
property Ref : pointer read GetRef;
property Parent : IXMLNode read GetParent;
property Document : IXMLDocument read GetDocument;
end;
IXMLNodeList = interface
['{C5393D52-8CB1-4E36-9A8D-25396C3C6716}']
function GetNodes(Index : integer) : IXMLNode;
function GetCount : integer;
property Nodes[Index : integer] : IXMLNode read GetNodes; default;
property Count : integer read GetCount;
end;
{ IXMLDocument }
IXMLDocument = interface
['{61715E40-F8D5-4A7E-A01B-80114EF35428}']
function GetDocumentNode : IXMLNode;
function GetEncoding : TXMLEncoding;
procedure New(aDocumentName : widestring = ''; anEncoding : TXMLEncoding = xeUTF8); // Once the encoding is set cannot be changed
procedure SaveToStream(aStream : TStream);
procedure SaveToFile(const aFileName : string);
procedure LoadFromStream(aStream : TStream);
procedure LoadFromFile(const aFileName : string);
function GetXML : widestring;
procedure SetXML(const Value : widestring);
function Transform(const XSL : string) : string;
property Encoding : TXMLEncoding read GetEncoding;
property DocumentNode : IXMLNode read GetDocumentNode; // NIL until New is called. New frees everything each time is called
property XML : widestring read GetXML write SetXML;
end;
function NewROXmlDocument : IXMLDocument;
function SelectNodeLocal(aParent: IXMLNode; const aLocalName: string): IXMLNode;
implementation
{$IFDEF RemObjects_MSXML}
uses uROMSXMLImpl;
{$ENDIF}
{$IFDEF RemObjects_OpenXML}
uses uROOpenXMLImpl;
{$ENDIF}
function SelectNodeLocal(aParent: IXMLNode; const aLocalName: string): IXMLNode;
var
i: Integer;
begin
result := nil;
if aParent = nil then exit;
for i := 0 to aParent.ChildrenCount -1 do begin
if aParent.Children[i].LocalName = aLocalName then begin
result := aParent.Children[i];
exit;
end;
end;
end;
function NewROXmlDocument : IXMLDocument;
begin
{$IFDEF RemObjects_OpenXML}
result := TROOpenXMLDocument.Create;
{$ENDIF}
{$IFDEF RemObjects_MSXML}
result := TROMSXMLDocument.Create;
{$ENDIF}
end;
end.