views:

97

answers:

2

what do I need to use XSLT 2.0 with Delphi(win32)? At the moment I use MSXML6 for all my xml transformation. But MSXML6 has no support for XSLT 2.0.

The solution (by ErvinS)
Using the AltovaXML library. After installation you have to import the AltovXML typelibrary. Then you can use a source like this:

procedure TfrmMainAltovaXmlDemo.btnTransformClick(Sender: TObject);
var
  xmlApp: AltovaXMLLib_TLB.Application;
  xslt2: AltovaXMLLib_TLB.XSLT2;
begin
  xmlApp := AltovaXMLLib_TLB.CoApplication.Create;
  xslt2 := xmlApp.XSLT2;
  xslt2.InputXMLFromText := FInputXml;
  xslt2.XSLFromText := FXslSource;
  FOutputXML := xslt2.ExecuteAndGetResultAsString;
end;
+1  A: 

As far as I know there is no XSLT 2.0 implmenentation for Delphi itself.
In general, there are only a few XSLT 2.0 implementations around.
Wikipedia has an overview of XSLT processors.

  • SAXON has an open source implementation of XSLT 2.0 in Java and .NET.
  • XJR is a paid implementation in C/C++.

You can integrate all of them in your Delphi apps.
Depending on how close you want to have such an integration, there are a few starting points:

--jeroen

Jeroen Pluimers
+3  A: 

Altova has AltovaXML, which is a free COM based component.

ErvinS
+1; now that is cool! I have updated http://en.wikipedia.org/wiki/Altova#Products and http://en.wikipedia.org/wiki/XML_template_engine#ImplementationsThanks!
Jeroen Pluimers
+1 for XSLT 2.0 free COM based recommendation.
Alejandro
@Alejandro: note that .NET can often be called as COM as well. Also note that COM usually is not my favourite means of integrating a 3rd party piece into my Delphi app.
Jeroen Pluimers
@Jeroen Pluimers: You are right. But allow people wich has not .Net platform aviable (or Java as well) to update to XSLT 2.0 is great, because I think we will wait MS for very long time...
Alejandro
@Jeroen: I'm not very fond of COM too, but Heinz specified that he is using MSXML. I personally use DIXml, but it doesn't support XSLT 2.0 yet.
ErvinS