Java

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  StyleVision Server API > Code Examples >

Java

The example below shows how to use Java code to generate an output RTF file using a PXF file and an input XML file. Ensure that StyleVision Server is installed and licensed and that it is available as a server object. Registration as a server object usually takes place during installation of StyleVision Server. To check if registration was successful, see About the Java Interface.

 

public class Program

{

 

  public static void main(String[] args)

   {

      try

      {

             

          //Create a StyleVision Server object

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

                   

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

          objSVS.setWorkingDirectory( "C:\\temp" );

     

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

          //In case you copied the JAR file to a new location, you need to explicitly set the path to the .exe file

          //objSVS.setServerPath( "C:\\Program Files (x86)\\Altova\\StyleVisionServer2019\\bin\\StyleVisionServer.exe" );

     

          //Prepare the name of the working XML

          objSVS.setInputXML( "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( "C:\\Program Files (x86)\\Altova\\StyleVisionServer2019\\etc\\Examples\\ExpReport.pxf" ) )

               System.out.println( "Success - finished execution" );

          else

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

       }

      catch ( Exception e)

       {

              e.printStackTrace();

       }

  }

 

}

 


© 2019 Altova GmbH