Suresh Kumar
Suresh Kumar

Reputation: 11757

XML design - How to?

We are currently working on the design of a RESTful application. We have decided on XML as our basic representation. I have the following questions regarding designing/modeling the application data in XML.

  1. What are the approaches towards data modeling in XML? Is it a good idea to start from scratch and then evaluate the use of standard XML schemas or vice versa?
  2. Where can I find information on all standard XML schemas?
  3. Should I start thinking of namespaces from the onset or is it something I can postpone for later?
  4. Finally, Is it good to start from designing the XML schemas first or start with XML document and then define a schema?

Note: I have already looked at a related question at stackoverflow (What are best practices for designing XML schemas?) but that doesn't seem to address the above questions.

Upvotes: 2

Views: 374

Answers (4)

Aruna
Aruna

Reputation: 51

Its better to think of namespace design approach from the start. If the XML files you are going to design are conceptually related you could go for homogeneous namespace design approach.

Heteregeneous namespace design approach allows for sharing and reusability. This could be used when you would like to visually identify domain-specific files.

The heterogeneous design approach is the recommended way. Refer http://technologyandleadership.com/three-schema-design-approaches/ to know how to implement this design approach for your project

Upvotes: 0

John Saunders
John Saunders

Reputation: 161773

I agree that you should first design your application, and decide on what information you need to exchange.

As you're doing that, you may possibly find that some of the information you're exchanging comes from standard schemas. You may also find that there are standard schemas used by your customers, that already describe the information you want to exchange.

If neither of these things occurs, then forget about "standard schemas". Among other things, I don't think you're going to find a comprehensive list of them - there are too many.

Upvotes: 0

Eugene Yokota
Eugene Yokota

Reputation: 95604

  1. You can do a lot with XML Schema, like abstract class, enumeration etc.. See XML Schema Part 0: Primer Second Edition. If you care about interoperability, try to stay away from certain data types.
  2. List of XML markup languages lists some known schemas. For POX on REST service I think you'd be making your own.
  3. As long as it's guaranteed unique, the actual name itself doesn't really matter. Include dates in there for future versioning.
  4. I think you should have ideas of how the resulting XML document should look like first.

One thing to note about service design is that it is different from designing class/object, and you have to think more in terms of exchanging documents. This is sometimes called course-grained. In OO world, you'd be exchanging series of method calls between peers, but in SOA, you'd avoid chattiness and try to stuff most of the information needed into a document, sort of like filing a tax form.

Upvotes: 1

Norbert Hartl
Norbert Hartl

Reputation: 10841

If you don't have an XML already and don't know the requirements than it will be hard to design the schema first. If you have code already that has to deal with XML than it may be the best idea to take the object tree as an example for your first XML tree. They aren't that different except that XML is always just a tree and your objects not.

From then one stabilize your XML and collect requirements what use cases should be modelled with it. If you have this two you have a perfect start to do an schema. This will solidize your format.

Looking for standard schemas is always a good idea but is almost all the time frustrating, too. Postpone this until you know what your xml will look like. Maybe then you recognize there is already something standardized that is just as your format.

You should be careful about namespaces. This is a more heavy weight topic in XML because you can do so much wrong. If you are not sure that you need them then skip. That is what the rest of the world is doing. If you think you will need them start at the very first to use them. Mixing none namespace aware code and namespace aware code is a pain.

Upvotes: 2

Related Questions