Altova StyleVision Server 2024

Este ejemplo explica cómo usar código C# para generar un archivo de salida RTF con un archivo PXF y un archivo XML de entrada.

 

Antes de empezar a probar el ejemplo, compruebe que cumple con estos requisitos:

 

StyleVision Server está instalado y tiene asignada una licencia válida.

StyleVision Server está disponible como objeto de servidor COM (este proceso suele tener lugar automáticamente durante la instalación de StyleVision Server. Consulte el apartado Información sobre la interfaz COM para obtener más información). Consulte también Información sobre la interfaz .NET.

 

namespace StyleVisionServerAPI_sample

{

  class Program

   {

      static void Main(string[] args)

       {

          try

          {

              //Create a StyleVision Server object

              Altova.StyleVisionServer.Server objSVS = new Altova.StyleVisionServer.Server();

 

              //Set a working directory - used for output and for intermediate files

              objSVS.WorkingDirectory = "..\\..\\..";

 

              //Default path to the StyleVision Server executable is the installation path (same dir with the StyleVisionServer.dll)

              //In case you moved the binaries on the disk, you need to explicitly set the path to the .exe file

              //objSVS.ServerPath = "C:\\Program Files (x86)\\Altova\\StyleVisionServer2024\\bin\\StyleVisionServer.exe";

 

              //Prepare the name of the working XML

              //    This can be an absolute/relative path if the file is stored externally (not inside PXF)

              // objSVS.InputXML = "ExpReport.xml";

              //    Or it can contain the path INSIDE the PXF

              // objSVS.InputXML = "ExpReport.pxf|zip\\ExpReport.xml";

              //    Easiest way is to refer to the file as being embedded in the transformation file

              objSVS.InputXML = "altova://packagedfile/ExpReport.xml";

 

              //Add output paths (absolute or relative to WorkingDirectory) for all formats that should be generated

              objSVS.OutputRTF = "C:\\tmp\\ExpReport.rtf";

 

              //Prepare the parameters, if your design uses parameters

              //objSVS.AddParameter( "testparam1", "value 1" );

 

              //Run the transformation; the output will be stored at C:\temp\ExpReport.rtf

              // NOTE Please adapt the path to the input file in order to run the sample

              if (objSVS.Generate("ExpReport.pxf"))

                  System.Console.WriteLine("Success - finished execution");

              else

                  System.Console.WriteLine(objSVS.LastExecutionMessage);

          }

          catch (System.Runtime.InteropServices.COMException ex)

           {

              // some general error like an invalid license happened

               System.Console.WriteLine("Internal Error - " + ex.Message);

           }

       }

   }

}

 

© 2017-2023 Altova GmbH