From GRP to SVG : How to from a console

We will cover in this chapter the different ways you dispose to transform your intermediary document (GRP document) to the graphical document (SVG document) from a console.

This mode of transformation is seldom used.

1. What is needed

To transform your GRP document to a SVG document, the Transformer needs the following things :

2. Passing parameters on the command line

2.1. Description

The class to instantiate is transformer.TransformerGRPToSVG.

The list of parameters is :

Attribute name Description Allowed values Default value Mandatory
-debug Enters in debug mode (the graphic shows the boxes and the springs, and information about the intermediary document is displayed). This parameter accepts no value. - No
-defs Specifies the Definitions document that contains the background definitions. Relative or absolute path to any Definitions document. - Yes
-grp_in Specifies the GRP document to transform. Relative or absolute path to any GRP document. - Yes
-height Specifies the height of the resulting graphic. Any positive real. If you specify this parameter, you must specify the -width parameter too. - No
-svg_dtd Specifies the SVG DTD (file name or URL). If you don't specify a value for this parameter, and if you don't use the parameter -svg_schema, it will be assumed that the file svg.dtd is present in the directory containing the XML document you intend to transform. If a file, relative or absolute path, or a URL to SVG DTD. - No
-svg_dtdoutput In the case the SVG Doctype is a file, specifies whether, inside the SVG document, path to SVG DTD is absolute or relative. absolute or relative. absolute No
-svg_dtdpublicID In the case the SVG Doctype is a URL, specifies the public ID of the Doctype. Any possible string for a public ID. - No
-svg_schema Specifies the SVG Schema (file name or URL). If a file, relative or absolute path, or a URL to SVG Schema. - No
-svg_schemanamespace Specifies the SVG Schema namespace. It must be the same than the namespace specified by the Schema you use. Any valid value for a namespace. - No
-svg_schemaoutput In the case the SVG Schema is a file, specifies whether, inside the SVG document, path to SVG Schema is absolute or relative. absolute or relative. absolute No
-svg_schemaxsi Specifies the SVG document namespace. Generally http://www.w3.org/2001/XMLSchema-instance. Any valid value for a namespace. http://www.w3.org/2001/XMLSchema-instance No
-width Specifies the width of the resulting graphic. Any positive real. If you specify this parameter, you must specify the -height parameter too. - No

Notes : if you specify the size of the resulting graphic with parameters -width and -height, the proportion of the graphic will be kept. Batik will ignore this size information, so TAXI will since it is based on Batik.

2.2. Examples

We will transform an existing GRP document shipped with TAXI : editor/XML/XML/ex1.cd.grp.

Note : these examples make the use of DTD only.

2.2.1. Example 1

For this first example, we will use the minimum required number of parameters.

Open a console and go to directory editor/XML/XML. Type the following command :

    java -cp ../../lib/taxi.jar fr.loria.taxi.transformer.TransformerGRPToSVG -grp_in ex1.cd.grp -defs definitionsCD.def -svg_dtd ../svg.dtd
  

You should obtain the following output :

    Parsing file definitionsCD.def
    Parsing file ex1.cd.grp
    Creating SVG document
    Generating SVG file ex1.cd.svg
  

Document ex1.cd.svg has been generated in directory editor/XML/XML. It looks like this :

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE svg SYSTEM "../svg.dtd">
    <svg height="186.0" width="308.0" x="0.0" y="0.0">
      ...
    </svg>
  

2.2.2. Example 2

We will produce an absolute path for SVG DTD.

Open a console and go to directory editor/XML/XML. Type one of the following commands, both produce the same result as -svg_dtdoutput is optional (the absolute path D:/editor/XML/svg.dtd is the one I have to use on my Windows machine) :

    java -cp ../../lib/taxi.jar fr.loria.taxi.transformer.TransformerGRPToSVG -grp_in ex1.cd.grp -defs definitionsCD.def -svg_dtd D:/editor/XML/svg.dtd
    java -cp ../../lib/taxi.jar fr.loria.taxi.transformer.TransformerGRPToSVG -grp_in ex1.cd.grp -defs definitionsCD.def -svg_dtd D:/editor/XML/svg.dtd -svg_dtdoutput absolute
  

You should obtain the following output :