This is a (compact) RelaxNG schema generated from (Most popular web site)
This is a (compact) RelaxNG schema generated from the sample file. You can use Trang to generate an XML Schema in exactly the same way, by giving the output file name the extension .xsd, for example: java -jar trang.jar rss2sample.xml rss2.xsd How It Works The operation of Trang is well beyond the scope of this book, but essentially it operates by parsing the source data and building an object model. This internal model reflects the entities and relationships defined in Relax NG. Where conversion is required, the data is converted into an abstract language that is intermediate between Relax NG and XSD, and any necessary transformation applied before the data is serialized out. More information about Trang can be found at www.thaiopensource.com/relaxng/ trang.html. An Object-Oriented Model: XML to Java There will be plenty of coverage of representing syndication data in object-oriented (OO) systems in later chapters, but by way of introduction there s a direct line that can be following from XML modeling into OO. The Relaxer tool (available for free at www.relaxer.org) is a Relax NG based schema tool similar to Trang, which offers certain additional facilities. These include generation of XSLT style sheets from schemas or instance data, and the facility of interest here, autogeneration of Java classes. The basic tool is another command- line application, and it couldn t be much easier to use. Once downloaded and installed, copy the rss2sample.xml file into the relaxer/bin directory. Then open a command window and type: relaxer rss2sample.xml If you look at the contents of the directory you will see the following files: . Channel.java . Item.java . Rss.java . RStack.java . UJAXP.java . URelaxer.java These files represent a (Java language) object-oriented model of an RSS feed. The last three files are used internally by the first three and can generally be ignored. Figure 20-9 illustrates the object-oriented model. 260 Chapter 20
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.