This second sample consists in three steps:
Compile the XSLT style sheet for all subsequent uses.
Invoke the XSLT engine to convert the input XML document to XSL-FO.
Invoke XMLmind XSL-FO Converter to convert the temporary XSL-FO file generated by second step to RTF.
Excerpts of samples/dotnet/Sample2.cs
:
using System.Xml.Xsl; using XmlMind.FoConverter; ... XslCompiledTransform transform = new XslCompiledTransform(); transform.Load(ToUri(xslPath)); string xmlUri = ToUri(xmlPath); foPath = Path.GetTempFileName(); transform.Transform(xmlUri, foPath); Converter converter = new Converter(); converter.OutputFormat = OutputFormat.Rtf; converter.OutputEncoding = "windows-1252"; converter.ImageResolution = 72; converter.BaseUrl = xmlUri; converter.SetInput(ToUri(foPath)); converter.SetOutput(rtfPath); converter.Convert(); ...
Compile the XSLT style sheet.
| ||||
Transform the XML input file to a temporary output file created in the system-dependant temporary file directory. | ||||
Create and parameterize a Converter object as explained in Section 2, “Converting an XSL-FO file to RTF”. | ||||
Setting the BaseUrl property to the URL of the XML input file is really needed in our case: If the XML input file references graphics files using relative URLs (example: An advanced alternative to specifying a | ||||
Perform the conversion by invoking Converter.Convert. |