How to visualize an XML schema programatically? [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing开发者_如何学运维 this post.
Closed 3 years ago.
Improve this questionI have made an XML Schema - all the code basically - and was wondering if there is a way that the code can generate something like this:
If so how can I do it?
The open source command line java application xsdvi creates an interactive diagram in SVG format from an XML Schema Definition. The generated SVG file can be displayed by a modern web browser where the user can expand and collapse the tree by mouse clicking.
Here is an example of a generated diagram
http://xsdvi.sourceforge.net/ipo.svg
The software can be downloaded from
http://sourceforge.net/projects/xsdvi/
It can be run as follows (assuming Java is installed and java.exe
is in the path):-
- Go to the
dist/lib
folder. - Run the following command
java -jar xsdvi.jar <input1.xsd> [<input2.xsd> [<input3.xsd> ...]] [style]
XSD Diagram is free (GNU open license), doesn't need to be built, and gives an interactive diagram. You just open the file and Add the types you want on the (initially blank) diagram. Pretty straight forward.
You can use XMLGrid's Online viewer which provides a great XSD support and many other features:
- Display XML data in an XML data grid.
- Supports XML, XSL, XSLT, XSD, HTML file types.
- Easy to modify or delete existing nodes, attributes, comments.
- Easy to add new nodes, attributes or comments.
- Easy to expand or collapse XML node tree.
- View XML source code.
Screenshot:
The Oracle JDeveloper 11g built-in viewer is in my view superior to the one available for Eclipse (which, in addition to other unfavourable comparison points I could only get to install for Indigo but not for Juno). If I am not mistaken Oracle makes the JDeveloper available for free (only requires registration at the OTN).
On Linux (with mono, available via apt-get
on Debian) and Windows:
- XSDDiagram (runs on Mono as well)
If you are on Windows I recommend you have a look at:
- XMLPad3 from WMHelp or
Both tools are free and both are able to provide similar visualizations as shown in your example.
If you need a simple, more text-oriented documentation of your XSD, check out xs3p - a XSLT stylesheet that will transform your XSD into more readable HTML format. Quite nice, and totally free.
If that's not enough, check out some of the commercial tools out there - I personally prefer the Liquid XML Studio - not as expensive as others, and quite as capable!
That picture is generated from a XML Schema editing tool, such as Altova's XMLSpy.
There are a number of XML tools around, all of which will include a Graphical XSD Viewer. I mentioned XML Spy simply because it is the brand leader. Also many general IDEs like Eclipse, Visual Studio and Oracle JDeveloper will be able to do this trick.
We offer a tool called DocFlex/XML XSDDoc that allows you to enjoy both things at once:
- To have diagram represetation of your XML schema
- To have all those diagrams embedded (and hyperlinked) in a highly sophisticated XML schema documentation
The diagrams in fact are generated not by us, but by Altova XMLSpy. We implemented an Integration with XMLSpy (with the full support of all diagram hyperlinks):
Here you can see the full this doc: http://www.filigris.com/docflex-xml/xsddoc/examples/html/XMLSchema/index.html
The whole thing provides a functionality not offered by any single vendor right now on the market!
Some our customers were so impressed that they purchased an extra license for XMLSpy only because of our tool. (That's no joke!)
Currently, we've also implemented similar integrations with other XML editors:
With <oXygen/> XML Editor:
See: http://www.filigris.com/docflex-xml/OxygenXML/demo/html/xslt20/index.html
With Liquid XML Studio:
See: http://www.filigris.com/docflex-xml/LiquidXML/demo/html/XMLSchema/index.html
Concerning what all those diagrams depict... Essentially, they are all about content model of XSD elements (as well as other XSD components that lead to elements: complexTypes, element/attribute groups). It seems, there are two approaches here:
- To show what a result content model (represented by the given component) would look. That's the approach of XMLSpy.
- To show how a particular content model (of the given component) was derived from other components. That's the approach of <oXygen/> XML and Liquid XML.
I personally believe that the diagrams generated by XMLSpy are more useful.
Yet, there were no attempts so far (at least known to me) to depict graphically anything else contained in XML schemas, although one can imagine many...
Visual Studio 2013 has a pretty cool visualizer built in.
File -> Open -> File pick your .xsd and then drag elements from XML Schema Explorer onto the designer surface.
There is a new free-to-use webtool, where you can view any xml schema:
Online XML Schema Viewer
www.xml-tools.net
It's written completely in JavaScript, so it's running in most modern browsers.
Here is my approach- download the freemind and CAM XML Template Editor.
Then open CAM XML, create new Template from XML, View -> View Template As Mind Map
Pros of this solution:
- It works locally, so secret files can be processed,
- totally free of charge,
- open source.
Cons:
- Quite unstable with large (more than 20sh MB) files.
We use Liquid XML Studio, it provides a intuitive editable representation of an XSD schema. It also shows the annotations inline, which we find very useful and the split code/gfx view is invaluable when writting or editing an XSD.
Try my xsd-viewer available from https://github.com/santhosh-tekuri/jlibs.
If someone works with IBM Rational Application Developer then XSD browser is built in it.
Grid-ML Schema Viewer is great for searching and visualizing XML Schemas: https://gridml.com/xml-schema-viewer. I find it better than other tools when it comes to large schemas or when browsing through a diagram is not feasible. The tool also allows you to copy the XPath or JSON path of the selection item.
Grid-ML Schema Search Screen
精彩评论