2

I am using mxsml 6 via COM to execute a transform. The source stylesheet has an xs:import statement that I know how to include, but how can I tell MSXML to do that? I can't seem to find a place to tell the IXSLTemplate to load the resolved source

Details:

  • I get the error "the system cannot locate the object specified"
  • I am setting the ResolveExternals = true on the source document
  • I am trying to execute a schematron validation
  • I am using Delphi, so using msxml seems to be my only option
  • I have everything in memory in a server environment, so I very much want to avoid having to use files

Code:

var
  v: variant;
  doc : IXMLDOMDocument2;
  xform: IXSLTemplate;
begin
  v := CreateOLEObject('MSXML2.FreeThreadedDOMDocument.6.0')
  doc := IUnknown(TVarData(v).VDispatch) as IXMLDomDocument2;
  doc.async := false;
  doc.resolveExternals := true;
  doc.loadXML([my source for the first transform below]);
  v := CreateOLEObject('MSXML2.XSLTemplate.6.0');
  xform := IUnknown(TVarData(v).VDispatch) as IXSLTemplate;
  xform.stylesheet := doc;
end;

original source for transforms:

Grahame Grieve
  • 3,538
  • 3
  • 15
  • 17
  • well, even if that problem can be solved - which looks unlikely - it's still not xslt 2. The Altova XML control is way easier to use (though has this same problem - have to use files) – Grahame Grieve Jun 10 '13 at 11:33
  • You might be interested in this question: http://stackoverflow.com/questions/8991755/how-do-i-resolve-xslimport-and-xslinclude-elements-with-relative-paths-whe?rq=1 (Although it is a .Net question.) – Baoquan Zuo Jun 11 '13 at 07:59
  • no. only .net has a solution for this – Grahame Grieve Feb 02 '15 at 21:15

1 Answers1

0

I'm not a delphi programmer, but I've done this often with C++ for MSXML4. Here is the vb code example from MSXML4 documentation, that I simply translated to C++.

 Dim xslt As New Msxml2.XSLTemplate40
 Dim xslDoc As New Msxml2.FreeThreadedDOMDocument40
 Dim xmlDoc As New Msxml2.DOMDocument40
 Dim xslProc As IXSLProcessor
 xslDoc.async = False
 xslDoc.Load "sample.xsl"
 Set xslt.stylesheet = xslDoc
 xmlDoc.async = False
 xmlDoc.Load "books.xml"
 Set xslProc = xslt.createProcessor()
 xslProc.input = xmlDoc
 xslProc.addParameter "param1", "Hello"
 xslProc.Transform
 MsgBox xslProc.output
Jim
  • 864
  • 1
  • 8
  • 16