RE: Re: What is XML For?
Just few comments... > > JAXB is a Java API, released just about now, that lets > you generate Java classes directly from a schema. By default > it's an obvious mapping, i.e. an attribute becomes a member > variable, but you can customise the mapping freely with an > XML template file, for example mapping an element to a > pre-existing class or specifying a class of your own that will > do the translation (both ways) for that element type. > > It seems that Castor (mentioned by Jeff Lowery) is similar, > but it works on existing Beans whereas JAXB generates new bean-like > classes? Castor can actually also generate beans from an XML Schema too. There are three types of use of the Marshalling Framework in Castor: 1- you have an XML schema (or a DTD) and no object model: castor can generate a Java object model from the XML schema as well as a set of classes that will hold the XML information needed to validate the data read or write. 2- you have an existing object model and you want to read/write XML from it by customizing Castor: you can configure a mapping file that will hold the mapping information between an XML document and your object model. 3- you have a set of beans: Castor will introspect them to read/write XML. You can also leverage those 3 approaches to fit your needs. More information on Castor is available at www.castor.org and will support JAXB in a future release. Arnaud > > So, to answer your question; you would instantiate objects > of these custom classes, initialise them and connect them up as > desired, then call a 'marshal' method for the root object, which > yields the XML. > > I've been trying the early-release implementation (based > on DTDs rather than schema) and I've enjoyed using it. It's a whole > lot more fun than running a DOM through an identity transformation. > When you want a 'customer' element, it's nice to be able to say > new Customer( "fred" ). > > David > > > ----------------------------------------------------------------- > The xml-dev list is sponsored by XML.org <http://www.xml.org>, an > initiative of OASIS <http://www.oasis-open.org> > > The list archives are at http://lists.xml.org/archives/xml-dev/ > > To subscribe or unsubscribe from this list use the subscription > manager: <http://lists.xml.org/ob/adm.pl>
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format