Altova StyleVision Server 2024

Este ejemplo muestra cómo usar código Java para generar un archivo RTF de salida con un archivo PXF y un archivo XML de entrada. Antes de empezar a probar el ejemplo, asegúrese de que StyleVision Server está instalado, tiene asignada una licencia válida y está disponible como objeto de servidor. Puede registrarlo como objeto servidor al instalar StyleVision Server. El programa de ejemplo que puede ver más abajo se puede generar y ejecutar con el archivo por lotes buildAndRun.bat, que se encuentra en la carpeta etc\Examples\Java de su carpeta de instalación de StyleVision Server.

 

Consulte el apartado Información sobre la interfaz Java para obtener más información.

 

Nota:es recomendable que copie la carpeta Examples a su directorio principal u otra ubicación adecuada, y después entre en la carpeta Java para acceder a Program.java y buildAndRun.bat.

 

 

Program.java

public class Program

{

 

  public static void main(String[] args)

   {

     com.altova.stylevisionserver.StyleVisionServer objSVS

      try

      {

          //Create a StyleVision Server object

          objSVS = new com.altova.stylevisionserver.StyleVisionServer();

         

          //The default location of server binary is the folder containing the Java native library

          //Select a different server binary with the following line:

          //obj.SVS.setServerPath(strServerPath);

 

         //The sample data is located in the parent folder of the Java sample code

         //Set this parent folder to be the working directory:

          objSVS.setWorkingDirectory( ".." );

                 

         System.out.println("Running " + objSVS.getProductNameAndVersion());

       

        //Prepare the name of the working XML

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

         //   objSVS.setInputXML( "ExpReport.xml" );

         //Or it can contain the path INSIDE the PXF

         //   objSVS.setInputXML( "C:\\Program Files (x86)\\Altova\\StyleVisionServer" + majorVersionYear + "\\etc\\Examples\\ExpReport.pxf|zip\\ExpReport.xml" );

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

         objSVS.setInputXML( "altova://packagedfile/ExpReport.xml" );

       

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

          objSVS.setOutputRTF( "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.out.println( "Success"  +  objSVS.getLastExecutionMessage() );

          else

               System.out.println( objSVS.getLastExecutionMessage() );

       }

      catch ( Exception e)

       {

          System.out.println(e.getMessage());

       }

  }

 

}

 

© 2017-2023 Altova GmbH