Altova StyleVision Server 2024

Im Beispiel unten wird gezeigt, wie Sie über Java-Code anhand einer PXF-Datei und einer XML-Input-Datei eine RTF-Output-Datei generieren. Stellen Sie sicher, dass StyleVision Server installiert und lizenziert ist und als Server-Objekt zur Verfügung steht. Die Registrierung als Serverobjekt erfolgt normalerweise während der Installation von StyleVision Server. Das unten stehende Beispielprogramm kann mit Hilfe der Batch-Datei buildAndRun.bat aus dem Ordner etc\Examples\Java Ihres StyleVision Server-Installationsverzeichnisses erstellt und ausgeführt werden.

 

Informationen zur Schnittstelle finden Sie unter Informationen zur Java-Schnittstelle.

 

Anmerkung:Es wird empfohlen, den Ordner "Examples" in Ihr Startverzeichnis oder einen andere geeignete Ordner zu kopieren und anschließend zum Java-Ordner zu navigieren, um Program.java und buildAndRun.bat aufzurufen.

 

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());

       }

  }

 

}

 

© 2018-2024 Altova GmbH