[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [xml-dev] Instantiating XML code from XML schema - Best practice(andwhat pratice)?
- From: Ronald Bourret <firstname.lastname@example.org>
- To: Erik Beijnoff <email@example.com>
- Date: Thu, 27 Sep 2001 15:48:32 -0700
I don't think that Castor (or any XML data binding product) is what you
are looking for. XML data binding creates data-specific objects from an
XML document. For example, if you have an XML document that represents a
sales order, the result of using a data binding product will be objects
like Order, Item, Customer, and Part. Other problems with data binding
are that data binding products generally ignore the order of sibling
elements and text in their parent and can't handle mixed content.
I think what you want is closer to a schema-driven editor. If you're
looking for a starting point, find a DTD-driven XML editor and modify
that to use schemas instead of DTDs. For a list of free editors, see:
> Erik Beijnoff wrote:
> First I'd like to say that I'm sorry to turn to you, since list is
> full of postings anyway, but it seems like nobody else can answer the
> question, I've tried a bunch of forums, but it looks like I'm on my
> own on this one.
> I'm trying to use xml schema as blueprints for xml files, using the
> xml schema as a class, sort of. The generated xml file would then be
> object created from the class. What I don't know is what technique I
> should use. Let me give you an example:
> 1. I want to be able to generate a basic XML file from an XML schema.
> Take a look at the way XML Spy generates a XML file from a Schema.
> When you create a new XML document and tie it to a Schema, the program
> generates a sort of "basic XML setup". I believe it creates the
> Elements which has it's minOccurs="1" or something like that. That
> really doesn't matter, I can take care of all the details, I just need
> advice on what approach to use.
> 2. And this is propably the most tricky one. I want to be able to put
> the cursor at any position in a XML document, then be able to add new
> elements as defined by the XML Schema for that element. In other
> words, if an element <a> has a XML schema defintion <xsd:element
> name="a"> that tells me that it is a complex type to which elements of
> type <elm1> and <elm2> can be added, I want to be able to press a
> button "Create Element" and then choose from a list of possible
> elements via a dropdown or something similar. Ideally, the element
> added should be added as defined in 1).
> This is supposed to be a normal client-server solution using Jsp and
> servlets. the closets I've gotten is Castor http://castor.exolab.org/
> which according to their specification can generate Java classes from
> Xml Schemas. But what they intend to use the classes for after that is
> only validation of existing xml files and for java-xml binding
> (marshalling and unmarshalling), not generating them. They don't
> mention generation anyway. But, I guess I can manage from there.
> So, as of know, I only see that I've got two solutions: either
> modifying castor for my own purposes or ripping out the guts of the
> schema parts of xerces and creating something from their validator. I
> hope somebody has some practical experiences or some ideas about a
> best practice. Thank you.