DVSL examples -- at some point these might be added to the Velocity DVSL documentation.

Java Streams makes DVSL usable in any Java App:

PrintWriter out = resp.getWriter();
DVSL dvsl = new DVSL();
Reader in = new InputStreamReader(System.in);    
dvsl.setStylesheet("e:/xdocs/example1.dvsl");
in = new FileReader("e:/xdocs/example1.xml");
dvsl.transform(in, out);
out.flush();

String realPath = this.getServletContext().getRealPath( "/" );
DVSL dvsl = new DVSL();
String inFile = request.getParameter( "inFile" );
String styleFile = request.getParameter( "styleFile" );
dvsl.setStylesheet( realPath + styleFile );
Reader in = new FileReader( realPath + inFile );
Writer out = new BufferedWriter( response.getWriter() );
dvsl.transform( in, out );
out.flush();

String realPath = this.getServletContext().getRealPath( "/" );
DVSL dvsl = new DVSL();
URL inURL = new URL( "http://www.server.com/weather.xml" );
String styleFile = request.getParameter( "styleFile" );
dvsl.setStylesheet( realPath + styleFile );
URLConnection uConnection = inURL.openConnection();
uConnection.connect();
InputStream is = uConnection.getInputStream();
Writer out = new BufferedWriter( response.getWriter() );
dvsl.transform( is, out );
out.flush();

DVSLExamples (last edited 2009-09-20 22:06:08 by localhost)