OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xml-dev] Instantiating XML code from XML schema - Best practice (andwhat pratice)?

Title: Instantiating XML code from XML schema - Best practice (and what pratice)?

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.