Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I display XML using an XSLT document, in a Delphi app?

Tags:

xml

xslt

delphi

I've been given a sample XML file (ultimately my client will receive several of these each day), and an XSLT file which will apparently transform the XML into something with a meaningful layout, suitable for displaying in a browser or printing.

I'd like to put something into an existing legacy Delphi app, such that the user can pick one of the XML files from the drive and 'display' it (in a TWebBrowser or similar).

I have no idea where to start, and Googling delphi, xml and xslt gets me examples that seem to be datamodule/database based; I just want to transform a given XML file into something on-screen. It looks like it might involve a PageProducer but I can't quite get my head around what I need to do. Anyone offer any pointers, or maybe a link to a quick tutorial?

Many thanks!

like image 752
robsoft Avatar asked Jun 11 '09 18:06

robsoft


1 Answers

Uses
  XMLDoc, XMLIntf;

function Transform(XMLContent : string; XSLContent : string) : WideString;
var
  XML : IXMLDocument;
  XSL : IXMLDocument;
begin

  XML := LoadXMLData(XMLContent);
  XSL := LoadXMLData(XSLContent);

  XML.DocumentElement.TransformNode(XSL.DocumentElement, Result)

end;
like image 168
Ken Byington Avatar answered Oct 12 '22 12:10

Ken Byington