• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Tools to generate XSD from POJO?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm looking for a command line tool which can generate an XSD from a Java object. The only restriction is Java 1.4 or below. Does anyone know of such a tool?

Thanks,
-Mike
 
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mike - There are probably better ways to approach this, but as a first cut I would:

a) In a little custom Java code, use a java.beans.XMLEncoder to convert the POJO to an XML instance. You may want to manually/automatically update the actual XML produced.

b) Then use (something like) XMLBeans from apache.org to read the XML instance and produce a schema (the 'inst2xsd' tool). And you will still probably need to tweak the schema produced.

That should not be too difficult if you just have a few POJO's to run through this. If you have many, consider some scripting glue to automate the whole process.

HTH, Guy
 
author
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also if you have some time look at JIBX framework, which can map your POJO to XML. That is my favourite XML--> POJO and vice versa framework.
 
Mike Monette
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to both of you for your replies. I'm trying to make the process as automated as possible. These aren't complicated objects, so hand-tuning the XML or XSD is not a big deal for a few, but as our project moves forward, the number of domain objects to run generation for increases.

The XSD's are required for mediation between POJO and Service Data Objects (SDO's). I'm starting with the Java domain objects, and need to generate XSD's for them at build time to feed into a mediation service, which will perform the translation.

If anyone has ideas on a better approach, I'd love to hear them.

Thanks,
Mike Monette
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic