1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
uses XSLProd, XMLDoc, XMLDOM;
{$R *.dfm}
function FusionXMLXSL (st1, st2 : string) : string ;
var
XMLDocument1 : TXMLDocument;
XSLPageProducer1: TXSLPageProducer;
begin
Result := '' ;
try
XMLDocument1 := TXMLDocument.Create(Application) ;
XMLDocument1.DOMVendor := DOMVendors.Find ('MSXML') ;
XSLPageProducer1 := TXSLPageProducer.Create(Application);
XSLPageProducer1.DOMVendor := DOMVendors.Find ('MSXML') ;
XMLDocument1.LoadFromXML(st1) ;
XSLPageProducer1.XMLData := XMLDocument1 ;
XSLPageProducer1.XML.text := st2 ;
Result := XSLPageProducer1.Content ; // ;FromString (sl2.Text) ;
finally
if (XMLDocument1 <> Nil) then XMLDocument1.Free;
if (XSLPageProducer1 <> Nil) then XSLPageProducer1.Free;
end;
end ;
procedure TForm1.Button1Click(Sender: TObject);
var
sl1,sl2 : TStringList ;
begin
sl1 := TStringList.create ;
sl1.LoadFromFile('aa1.xml');
sl2 := TStringList.create ;
sl2.LoadFromFile('aa1.xsl');
Memo1.lines.Text := FusionXMLXSL (sl1.Text,sl2.Text) ;
sl1.Free ;
sl2.Free ;
end;
end. |
Partager