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

后端 未结 4 1368
半阙折子戏
半阙折子戏 2020-12-03 03:37

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 wit

相关标签:
4条回答
  • 2020-12-03 04:09
    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;
    
    0 讨论(0)
  • 2020-12-03 04:12

    I used an MSXML library to do the XSLT transformation in Delphi. It was a long time ago. Worked like a charm!

    I'm not sure what output format your XSLT will generate, but knowing that will help you figure out how to display it. We generated HTML from XML via XSLT, and displayed it using an ActiveX Web Browser (IE) control on a pane in our application.

    Here's a link on MSSXML and Delphi that might help.

    BTW: If this is your first time working with XSLT, you can manually edit an XML file, and add in a directive to get it to display using a specific XSLT. When you open the XML in Firefox after the edit, the XSLT will be applied, and it will show you what will be the output of your MSXML calls. Here's the line you add manually to the xml:

    <?xml-stylesheet type="text/xsl" href="myStyleSheet.xsl"?>
    
    0 讨论(0)
  • 2020-12-03 04:21

    If you need only transformations, you can use TXMLDocument, save to disk and than display the result in a TWebBrowser (via Navigate('file:///...')).

    Personally I had some problems with MSXML so I started to use DIXML.

    0 讨论(0)
  • 2020-12-03 04:28

    You can try install the AltovaXML, it can be call as a COM+. It is free and can be download from: http://www.altova.com/altovaxml.html

    MsXml can only works with xslt 1.0 but AltovaXml can work with xslt 2.0

    0 讨论(0)
提交回复
热议问题