My EJB3 book

EJB 3 at JBoss Logo

[ ] [ Start ] [ Install etc. ] [ Changelog ] [ Todos ] [ SourceForge] [ Symbols ] [ Properties ] [ JavaDoc ] [ FreshMeat ] [ Ohloh ] [ Browse source ]




To use x2svg, you need fop and dtdparser, which need to be present in the lib/ folder. In addition you need ant to build the distribution and use x2svg as ant tasks in build scripts.

Dependencies like FOP and DTDParser can now be pulled down by executing:

ant pull-dependencies
This also pulls ant.jar into lib/ from the ant distribution.

Those dependencies can also manually be obtained from:

Unzip the distributions into the lib/ folder of the x2svg project. The file structure should look like this:
Directory structure of x2svg distro

Building x2svg

Go into the project and call ant. This should build all the necessary files for you.
The build file knows those targets:

Running x2svg

To run the application, you need to put a big number of libs on the classpath.
To make this easier, you can use the script on unix, which accepts the same command line as the X2Svg java class: [options] inputfile [root-element]
Options are: Example:
 sh -c /tmp/test.pdf -o /tmp/test.svg sample.dtd root
The ant buildfile build.xml shows how to run this from an ant script in the run-sample target.

Note that option -c can be given multiple times.
X2svg usually tries to determine the output file type from looking at the suffix (e.g. .pdf), but this can be overridden by giving a target type in the optional :type part. If you want you can specify the type multiple times to convert into all of those target types. The type specifications need to be given next to each other then (as in -c
It is also possible to only speficy the type (as in -c :pdf). In this case x2svg will determine the output file name by chopping off the .svg from the input file name and appending the standard suffix for the given type.
It is as well possible to give an output directory with a file type only (as in -c foo/:png. In this case the output will be written into directory foo/ and the filename will be deviated from the input filename.

The Graphical user interface

X2svg has since version 1.1-gui a graphical user interface. You can start it by running the class de.bsd.x2svg.gui.X2SvgGui or use one of the start scripts runGui.bat or After starting, the GUI will show a window like this (here in German locale):
Image of the x2svg GUI
The first two rows are used to select the input file and the svg output file. The two buttons labeled with '...' will show file selector boxes to browse the file system.
If the checkbox is checked (as shown), then x2svg will also try to convert the generated svg file into another output format (see below for formats).
On the next line, you can enter a comment that will printed on the generated diagram. If the checkbox is markd, a default comment from the properties file will be used. See here for supported substitutions.
Pressing the Start button will start the conversion.
If you checked the "Show svg option", a second window will appear after the conversion that shows the gnerated SVG. You can scroll around and use the '++','--','1:1' and 'x' controls to zoom in, zoom out reset the size and center the display. See also this screenshot.

Supported output types other than svg

Run the svg converters

The output converter SvgConverter can also be used standalone:
java de.bsd.x2svg.outputConverter.SvgConverter type(s) input.svg output[.type] [output dir]
As this also needs a bunch of libraries installed, a shell script is provided as well.


This paragraph describes the various parsers present in the system.


This parser is able to parse Document type descriptions (DTD). If no root-element is given on the command line, it will try to guess the root element. If the parsers specific option '-d <depth>' is given, then the depth of the tree is limited to depth levels instead of unlimited. This parer supports parsing of attributes.

Build.xml Parser

This parser is able to parse ant build.xml files. It will by default graph the call tree when you just call ant on that buildfile without any targets (so it will use the default target). By giving the '-f' option, it will go trough the build file and will graph a forest of all targets.

Properties Parser

This parser will just display all properties in a property file and is mostly meant as an example to start writing own parsers.

XML Schema Parser

This parser is able to parse (some) XML Schema files. As it is still not finished, it might not parse your schema.
By default, you need to give the name of the root element to parse. It now also understands a few more options: This parer supports parsing of attributes.

Ant tasks

There are a set of ant tasks that allow X2SVG to be used in any Ant-based automated build. This can be incredibly useful for generating documentation as part of an automated build process, or for parsing large and diverse content sets very simply.

To use X2SVG, simply ensure that X2SVG.jar is available on the ant classpath (either project specific, or put in $ANT_HOME/lib for global availability of the X2SVG tasks.

Full documentation for the ant tasks can be found here.


 * Copyright (c) 2007,2008 Heiko W. Rupp. 	All rights reserved. 
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *  This software is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: