You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Tarek Hammoud <ma...@c158163-a.mntp1.il.home.com> on 2000/10/12 05:59:35 UTC

XML Newbie questions

Hello,

I have a design question and will appreciate any input. We have an
object model represented in Rational Rose. We use the model to
generate our Java code and data objects. These objects are served to
our Java clients using a WebLogic server. We would like to serve these
objects to our C++ clients using XML. In addition, we would like to
allow the C++ client to modify the documents and submit the changes.

First I do hope that this is the right news group for this. If not, please
help and point me to the proper group.

Since we have the object model in Rational Rose, we decided to take
the following approach:

1- Create an XML schema that represents the domain object.
2- Write a Marshall class that introspects the Java object and consults
   the XML schema before outputing the elements or attributes.
3- All Java basic data types (i.e including dates and Strings) are mapped
   to native XML schema types. Objects are mapped to elements.
4- For evey object defined in Rose, a complex type is defined in the XML schema.
5- All objects referenced from the domain object (including superclasses) are
   a generated in the same schema file. We are modelling securities. This
   will result in referenced objects being duplicated in multiple schemas.
   We felt that having all needed objects in the same schema will make it
   easier for schema readers. The other approach will have involved creating
   a schema for every reachable object and importing the schemas where needed.
6- Inherited or reachable objects can come from different java packages. Thus
   for each package name we came up with a way to come up with a short name for 
   the namespace. A namespace is contrived from the package name.
7- The class that serializes the object to XML uses XPath rather than direct
   manipulation of the DOM.

This works very nicely in our alpha release but I have several questions and
concerns being a newbie at XML and schemas.

- When we write the XML out to the stream, should we create a DOM and then
  use some utility class (anyone ?) to transform the DOM to an XML document ?
  We currently write XML using streams.

- Should we stick with our method of "including" all complex type definitions
  represnting domain objects in the same schema file or should we define
  separate schemas and then import each where needed ? 

- What happens if multiple (different) security types need to exist in the 
  same XML document ? What will the parser do if multiple imports of the same 
  data type takes place as a result of multiple schemas ? Or if the schemas
  are self contained, which might result in duplicate definitions in the same
  name space ?

- Is XPath fast enough (haven't done any timings) ? or should we maipulate DOM 
  directly ?

- Is our choice in 3 correct given the rich types defined in XML schema or
  should we have used elements instead ?

- Since we are including all definitions in the same schema, for every reachable 
  object (which might come from a different java package) we are defining a name
  space that corresponds to the package name. The target name space is derived
  from the root object being generated. How do we associate a different name
  space with the complexType element if the object comes from a different package ?


Tarek Hammoud
Citadel Investment Group.