DVSL (Declarative Velocity Style Language) is a tool modeled after XSLT and is intended for general XML transformations. DVSL steals two of the best features of XSLT:
DVSL's template language is Velocity, so conventional Velocity syntax is used to get and set data, to perform looping and flow control, etc. Anything that you can normally do in a Velocity template can be done in DVSL templates.
Before you use DVSL, you must get the source and build the tool. Currently, there is no release, so you must either get a nightly snapshot, or download directly from CVS.
How to BuildBuilding DVSL is very simple. All dependency jars that are required are included in the distribution. However, we do require that Jakarta Ant is installed.
Once ant is installed, you simply need to change to the project root directory and invoke ant with the 'jar' target :
This will build the dvsl jar in the project root directory.
Using DVSLWhile DVSL is also a tool that can be integrated into your applications, DVSL is able to be used without any programming.
The first way is via command line, where you can use it to transform a single file, or as a filter. The usage is :
java org.apache.tools.dvsl.DVSL -STYLE stylesheet [-IN infile] [-OUT outfile ]
Note that the stylesheet is the only required element, and the input and output then default to
stdin and stdout.
By adding the appropriate stuff in your classpath (that would be all the jars in the project
lib directory ), you can use it :
You can also use DVSL right from ant using the included Ant task. The Ant task supports the toolbox.
For more information on using DVSL from Ant, please see the Ant Task Reference.
A few examples are provided with the current distribution, in the examples
directory in the distribution, and the examples that follow were originally taken
from there.
To begin, we will start with a simple example. Here is a basic XML document:
Hello from section foo
Hello from section bar
A simple DVSL stylesheet to transform this into HTML might look like :
$node.copy($node.children())#end ]]>
With the resulting output of
Hello from section foo
Hello from section bar