Code Generation With XSL, Page 3
Generated Java Bean
To view the complete generated program, click here.
Think of how much time it would take to hand code this class versus the time spent to author the meta data file. And the generated code will compile and run properly the first time.
XSL can do more than transform XML into other markup languages. It is an excellent code generation language. Meta data can be quite naturally structured in XML. XSL can easily process the meta data via a "pull" or rules-based fashion and invoke code fragments in modular templates.
We developed a JavaBean generator to demonstrate the concept. XSL techniques such as modes and called routines were used to modularize the code. The code generation technique demonstrated here could also be used to generate EJB classes, JDBC code, or classes running on a framework like Struts. But the rest is up to you.
To download the example XML stream and stylesheet, click here.
About the Author
|Jeff Ryan is an architect for Hartford Financial Services. He has eighteen years of experience designing and developing automated solutions to business problems. His current focus is on Java, XML, and Web Services technology. He may be reached at email@example.com.|
|Other Articles Written by Jeff Ryan|