[howto.xml]
XML Version = "1.0"?>
topic>
topic>
topic>
topic>
howto>
[howto.xsl]
XML Version = "1.0"?>
Version = "1.0">
Title TH> | URL TH>
TR> |
---|---|
| TR> xsl: for-energy> table> body> html> xsl: template> xsl: stylesheet> [Howtoxslt.java] // jdk1.4.1 Import javax.xml.transform. *; Import java.net. *; Import java.io. *; Public class howtoxslt { Public static void main (String [] args) { Try { TransformerFactory Tfactory = TransformerFactory.newInstance (); TRANSFORMER TRANSFORMER = Tfactory.NewTransformer (New javax.xml.transform.Stream.StreamSource ("howto.xsl")); Transformer.Transform (New Javax.xml.Transform.Stream.StreamSource ("Howto.xml"), New javax.xml.transform.Stream.StreamResult NEW FileOutputStream ("Howto.html"))) } Catch (Exception E) { E.PrintStackTrace (); } } } Howto.html is shown as: TitleURLJavahttp: //www.rgagnon/javahowto.htmPowerBuilderhttp: //www.rgagnon/pbhowto.htmJavascripthttp: //www.rgagnon/jshowto.htmVBScripthttp: //www.rgagnon/vbshowto.htm You can also specify a style sheet in HOWTO.XML: XML Version = "1.0"?> xml-stylesheet href = "howto.xsl" type = "text / xsl"?> topic> topic> topic> topic> howto> An example of an practical application of XSTL: You can scan changes in CVS in the CVS in the following scripts and generate reports: Destfile = "$ {build_dir} /changelog.xml" Usersfile = "$ {build_dir} /properties/usersfile.properties" DaysinPast = "1" /> |