Sunday, September 16, 2012

Generating graphical representation of XSD (XML schema).

Question: Have you ever seen the graphical representaiton of XSD in a way XMLSpy is capable of generating?

Did you ever need to generate similar output via free/open source tools?

Answer: XSD Diagram (

When searching for the alternative couple years ago, that was my choice and I didn't regret since then,

Usage is very simple, let's see how works. I'll go step by step in a usage. For a real world example I use as a sample for the xsd the following one (standard web application descriptor schema):

  1. Start XSDDiagram.exe and choose File -> Open (open the downloaded xsd file)
  2. Error is thrown: "Could not find file 'dir/web-common_3_0.xsd'."
  3. OK, so we need reffered xsds as well. Let's get the rest then (web-common_3_0.xsd, javaee_6.xsd, jsp_2_2.xsd and javaee_web_services_client_1_3.xsd).
  4. Copy them to the same dir and reopen the original xsd again.
  5. Click the button in toolbar "Add all toplevel elements"

    or just choose the element you are interested in and click "Add selected toplevel element"
  6. Click multiple times (till all the levels are expanded) the button in toolbar "Expand one level"

    or just click the + sign for those elements you're interested in.
  7. Choose File -> Export Diagram -> (choose the file type feasable for your use case, I chose svg) and save.
  8. You're done!
Output could look like this (please note that schema graphical representation in this case is huge):